ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2024-05-10 00:25:22
Exec Total Coverage
Lines: 9280 12287 75.5%
Functions: 347 400 86.8%
Branches: 7401 13678 54.1%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 #include "zc/combos.h"
26 extern particle_list particles;
27
28 extern FFScript FFCore;
29 extern ZModule zcm;
30 extern HeroClass Hero;
31 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
32
33 int32_t repaircharge=0;
34 bool adjustmagic=false;
35 bool learnslash=false;
36 int32_t wallm_load_clk=0;
37 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
38 int32_t vhead=0;
39 int32_t guycarryingitem=0;
40
41 char *guy_string[eMAXGUYS];
42
43 void never_return(int32_t index);
44 void playLevelMusic();
45
46 // If an enemy is this far out of the playing field, just remove it.
47 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
48 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
49 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
50 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
51
52 1111957 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
53 {
54 1111957 int32_t c = coord.getInt();
55
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 1111690 times.
1111957 if(nearest_half)
56 {
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111690 times.
1111690 if (c < 0)
58 c -= val / 2;
59 1111690 else c += (val/2);
60 1111690 }
61 1111957 c -= c % val;
62 1111957 coord = c;
63 1111957 }
64
65 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
66 {
67 return
68 (
69 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
70 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
71 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
72 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
73 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
74 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
75 );
76 }
77
78 namespace
79 {
80 int32_t trapConstantHorizontalID;
81 int32_t trapConstantVerticalID;
82 int32_t trapLOSHorizontalID;
83 int32_t trapLOSVerticalID;
84 int32_t trapLOS4WayID;
85
86 int32_t cornerTrapID;
87 int32_t centerTrapID;
88
89 int32_t rockID;
90 int32_t zoraID;
91 int32_t statueID;
92 }
93
94 369 void identifyCFEnemies()
95 {
96 369 trapConstantHorizontalID=-1;
97 369 trapConstantVerticalID=-1;
98 369 trapLOSHorizontalID=-1;
99 369 trapLOSVerticalID=-1;
100 369 trapLOS4WayID=-1;
101 369 cornerTrapID=-1;
102 369 centerTrapID=-1;
103 369 rockID=-1;
104 369 zoraID=-1;
105 369 statueID=-1;
106
107
2/2
✓ Branch 0 taken 188928 times.
✓ Branch 1 taken 369 times.
189297 for(int32_t i=0; i<eMAXGUYS; i++)
108 {
109
3/4
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 188564 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 364 times.
188928 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
110 364 trapLOSHorizontalID=i;
111
4/4
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 188553 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
112 369 trapLOSVerticalID=i;
113
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 188559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
114 369 trapLOS4WayID=i;
115
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 188559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
116 369 trapConstantHorizontalID=i;
117
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 188559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
118 369 trapConstantVerticalID=i;
119
120
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 188559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
121 369 cornerTrapID=i;
122
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 188559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
123 369 centerTrapID=i;
124
125
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 188559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
126 369 rockID=i;
127
4/4
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 188540 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 367 times.
188928 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
128 367 zoraID=i;
129
130
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 188500 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 369 times.
188928 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
131 369 statueID=i;
132 188928 }
133 369 }
134
135 32 int32_t random_layer_enemy()
136 {
137 32 int32_t cnt=count_layer_enemies();
138
139
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
140 {
141 return eNONE;
142 }
143
144 32 int32_t ret=zc_oldrand()%cnt;
145 32 cnt=0;
146
147
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
148 {
149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tmpscr->layermap[i]!=0)
150 {
151 32 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
152
153
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
154 {
155
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
156 {
157
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
158 {
159 32 return layerscreen->enemy[j];
160 }
161
162 108 ++cnt;
163 108 }
164 108 }
165 }
166 }
167
168 return eNONE;
169 32 }
170
171 49 int32_t count_layer_enemies()
172 {
173 49 int32_t cnt=0;
174
175
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
176 {
177
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if(tmpscr->layermap[i]!=0)
178 {
179 79 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
180
181
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
182 {
183
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
184 {
185 420 ++cnt;
186 420 }
187 790 }
188 79 }
189 294 }
190
191 49 return cnt;
192 }
193
194 211789 int32_t hero_on_wall()
195 {
196 211789 zfix lx = Hero.getX();
197 211789 zfix ly = Hero.getY();
198
199
200 //zprint2("hero_on_wall x is: %d\n", lx);
201 //zprint2("hero_on_wall y is: %d\n", ly);
202
203
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=192)
204 {
205
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
206
207
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==128) return down+1;
208 180473 }
209
210
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=112)
211 {
212
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
213
214
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==208) return right+1;
215 172303 }
216
217 210948 return 0;
218 211789 }
219
220 765533 bool tooclose(int32_t x,int32_t y,int32_t d)
221 {
222
2/2
✓ Branch 0 taken 567824 times.
✓ Branch 1 taken 197709 times.
765533 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
223 }
224
225 3989892 bool enemy::overpit(enemy *e)
226 {
227 // This function (and shadow_overpit) has been broken since it was written, and only
228 // checked the same diagonal of the hitbox, over and over again. The bug is because both
229 // loops used the same variable name.
230 // Checking literally every pixel seems like overkill, so for now let's continue to
231 // do the single diagonal but just once. That's why the outer loop is commented out.
232
233 // for ( int32_t q = 0; q < hxsz; ++q )
234 {
235
2/2
✓ Branch 0 taken 36952798 times.
✓ Branch 1 taken 3970690 times.
40923488 for ( int32_t q = 0; q < hit_height; ++q )
236 {
237 //check every pixel of the hitbox
238
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 36933596 times.
36952798 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
239 {
240 //if the hitbox is over a pit, we can't land
241 19202 return true;
242 }
243 36933596 }
244 }
245 3970690 return false;
246 3989892 }
247
248 12250308 bool enemy::shadow_overpit(enemy *e)
249 {
250 // for ( int32_t q = 0; q < hxsz; ++q )
251 {
252
2/2
✓ Branch 0 taken 176046749 times.
✓ Branch 1 taken 12223847 times.
188270596 for ( int32_t q = 0; q < hit_height; ++q )
253 {
254 //check every pixel of the hitbox
255
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 176020288 times.
176046749 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
256 {
257 //if the hitbox is over a pit, we can't land
258 26461 return true;
259 }
260 176020288 }
261 }
262 12223847 return false;
263 12250308 }
264
265 // Returns true iff a combo type or flag precludes enemy movement.
266 7430873 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
267 {
268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7430873 times.
7430873 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
269 7430873 int32_t c = COMBOTYPE(dx,dy);
270
4/4
✓ Branch 0 taken 4890323 times.
✓ Branch 1 taken 2540550 times.
✓ Branch 2 taken 1398325 times.
✓ Branch 3 taken 1142225 times.
9971423 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
271
3/6
✓ Branch 0 taken 2522226 times.
✓ Branch 1 taken 4908647 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2522226 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7430873 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_qr(qr_DROWN));
272
5/6
✓ Branch 0 taken 2581772 times.
✓ Branch 1 taken 4849101 times.
✓ Branch 2 taken 2579895 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2579895 times.
✗ Branch 5 not taken.
14862510 return c==cPIT || c==cPITB || c==cPITC ||
273
4/6
✓ Branch 0 taken 2579895 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2579895 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2431147 times.
✓ Branch 5 taken 148748 times.
2579895 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
274 // Block enemies type and block enemies flags
275
2/2
✓ Branch 0 taken 2574619 times.
✓ Branch 1 taken 2425871 times.
148748 combo_class_buf[c].block_enemies&1 ||
276
4/4
✓ Branch 0 taken 2571949 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2571702 times.
✓ Branch 3 taken 247 times.
2574619 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
277
4/4
✓ Branch 0 taken 2570884 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2570818 times.
✓ Branch 3 taken 66 times.
2571702 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
278 // Check for ladder-only combos which aren't dried water
279
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2560192 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5141341 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
280 // Check for drownable water
281
4/4
✓ Branch 0 taken 572182 times.
✓ Branch 1 taken 1998341 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 570282 times.
2570523 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
282 2584413 }
283
284 // Returns true iff enemy is floating and blocked by a combo type or flag.
285 8647530 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
286 {
287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8647530 times.
8647530 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
288
4/4
✓ Branch 0 taken 6549648 times.
✓ Branch 1 taken 2097882 times.
✓ Branch 2 taken 1749423 times.
✓ Branch 3 taken 348459 times.
10745412 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
289
3/4
✓ Branch 0 taken 6564155 times.
✓ Branch 1 taken 2083375 times.
✓ Branch 2 taken 2083375 times.
✗ Branch 3 not taken.
10730905 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
290
2/2
✓ Branch 0 taken 1200911 times.
✓ Branch 1 taken 7446619 times.
16094149 return ((special==spw_floater)&&
291
2/2
✓ Branch 0 taken 7436494 times.
✓ Branch 1 taken 10125 times.
7446619 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
292
2/2
✓ Branch 0 taken 7436375 times.
✓ Branch 1 taken 119 times.
7436494 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
293
2/2
✓ Branch 0 taken 7436204 times.
✓ Branch 1 taken 171 times.
7436375 (MAPFLAG(dx,dy)==mfNOENEMY)||
294
2/2
✓ Branch 0 taken 7435949 times.
✓ Branch 1 taken 255 times.
7436204 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
295
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6193420 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14867894 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
296
2/2
✓ Branch 0 taken 6183831 times.
✓ Branch 1 taken 1248114 times.
7431945 (pit_blocks && ispitfall(dx,dy))));
297 8647530 }
298 // Returns true iff a combo type or flag precludes enemy movement.
299 268958 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
300 {
301 268958 int32_t c = COMBOTYPE(dx,dy);
302 268958 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
303
2/2
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 235501 times.
268958 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_qr(qr_DROWN);
304
5/6
✓ Branch 0 taken 268938 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 268821 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 268821 times.
✗ Branch 5 not taken.
1014723 return c==cPIT || c==cPITB || c==cPITC ||
305
4/6
✓ Branch 0 taken 268821 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268821 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239045 times.
✓ Branch 5 taken 29776 times.
268821 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
306 // Block enemies type and block enemies flags
307
2/2
✓ Branch 0 taken 268248 times.
✓ Branch 1 taken 238472 times.
29776 combo_class_buf[c].block_enemies&1 ||
308
4/4
✓ Branch 0 taken 267922 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 267891 times.
✓ Branch 3 taken 31 times.
268248 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
309
4/4
✓ Branch 0 taken 264391 times.
✓ Branch 1 taken 3500 times.
✓ Branch 2 taken 264116 times.
✓ Branch 3 taken 275 times.
267891 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
310 // Check for ladder-only combos which aren't dried water
311
4/4
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 263074 times.
✓ Branch 2 taken 1003 times.
✓ Branch 3 taken 39 times.
528193 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
312 // Check for drownable water
313
4/4
✓ Branch 0 taken 42399 times.
✓ Branch 1 taken 221678 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 18395 times.
264077 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
314 }
315
316 // Returns true iff enemy is floating and blocked by a combo type or flag.
317 122271 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
318 {
319
2/2
✓ Branch 0 taken 119948 times.
✓ Branch 1 taken 2323 times.
122271 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
320 122271 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122271 times.
244542 return ((special==spw_floater)&&
322
2/2
✓ Branch 0 taken 122174 times.
✓ Branch 1 taken 97 times.
122271 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
323
2/2
✓ Branch 0 taken 122169 times.
✓ Branch 1 taken 5 times.
122174 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
324
2/2
✓ Branch 0 taken 122160 times.
✓ Branch 1 taken 9 times.
122169 (MAPFLAG(dx,dy)==mfNOENEMY)||
325
2/2
✓ Branch 0 taken 122131 times.
✓ Branch 1 taken 29 times.
122160 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
326
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 119810 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
244012 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
327
2/2
✓ Branch 0 taken 119810 times.
✓ Branch 1 taken 2071 times.
121881 (pit_blocks && ispitfall(dx,dy))));
328 }
329
330 /**********************************/
331 /******* Enemy Base Class *******/
332 /**********************************/
333
334
4/8
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114505 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114505 times.
✗ Branch 7 not taken.
229010 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
335 114505 {
336
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 x=X;
337
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 y=Y;
338 114505 id=Id;
339 114505 clk=Clk;
340
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 floor_y=y;
341 114505 ceiling=false;
342 114505 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
343 114505 grumble = movestatus = posframe = timer = ox = oy = 0;
344
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114505 times.
✓ Branch 2 taken 114505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114505 times.
✗ Branch 5 not taken.
114505 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
345 114505 did_armos=true;
346 114505 script_spawned=false;
347
348 114505 d = guysbuf + (id & 0xFFF);
349 114505 hp = d->hp;
350 114505 starting_hp = hp;
351 // cs = d->cset;
352 //d variables
353
354 114505 flags=d->flags;
355 114505 flags2=d->flags2;
356 114505 s_tile=d->s_tile; //secondary (additional) tile(s)
357 114505 family=d->family;
358 114505 dcset=d->cset;
359 114505 cs=dcset;
360
2/2
✓ Branch 0 taken 88380 times.
✓ Branch 1 taken 26125 times.
114505 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
361 114505 dp=d->dp;
362 114505 wdp=d->wdp;
363 114505 wpn=d->weapon;
364 114505 wpnsprite = d-> wpnsprite; //2.6 -Z
365 114505 rate=d->rate;
366 114505 hrate=d->hrate;
367
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 dstep=d->step;
368 114505 homing=d->homing;
369 114505 dmisc1=d->misc1;
370 114505 dmisc2=d->misc2;
371 114505 dmisc3=d->misc3;
372 114505 dmisc4=d->misc4;
373 114505 dmisc5=d->misc5;
374 114505 dmisc6=d->misc6;
375 114505 dmisc7=d->misc7;
376 114505 dmisc8=d->misc8;
377 114505 dmisc9=d->misc9;
378 114505 dmisc10=d->misc10;
379 114505 dmisc11=d->misc11;
380 114505 dmisc12=d->misc12;
381 114505 dmisc13=d->misc13;
382 114505 dmisc14=d->misc14;
383 114505 dmisc15=d->misc15;
384 114505 dmisc16=d->misc16;
385 114505 dmisc17=d->misc17;
386 114505 dmisc18=d->misc18;
387 114505 dmisc19=d->misc19;
388 114505 dmisc20=d->misc20;
389 114505 dmisc21=d->misc21;
390 114505 dmisc22=d->misc22;
391 114505 dmisc23=d->misc23;
392 114505 dmisc24=d->misc24;
393 114505 dmisc25=d->misc25;
394 114505 dmisc26=d->misc26;
395 114505 dmisc27=d->misc27;
396 114505 dmisc28=d->misc28;
397 114505 dmisc29=d->misc29;
398 114505 dmisc30=d->misc30;
399 114505 dmisc31=d->misc31;
400 114505 dmisc32=d->misc32;
401
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 110429 times.
114505 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
402 {
403 110429 dmisc31 = dmisc32;
404 110429 dmisc32 = 0;
405 110429 }
406 114505 spr_shadow=d->spr_shadow;
407 114505 spr_death=d->spr_death;
408 114505 spr_spawn=d->spr_spawn;
409
410
2/2
✓ Branch 0 taken 4694705 times.
✓ Branch 1 taken 114505 times.
4809210 for(int32_t i=0; i<edefLAST255; i++)
411 4694705 defense[i]=d->defense[i];
412
413 114505 bgsfx=d->bgsfx;
414 114505 hitsfx=d->hitsfx;
415 114505 deadsfx=d->deadsfx;
416 114505 bosspal=d->bosspal;
417 114505 parent_script_UID = 0;
418
419 114505 frozentile = d->frozentile;
420
421 114505 frozencset = d->frozencset;
422 114505 frozenclock = 0;
423
2/2
✓ Branch 0 taken 1145050 times.
✓ Branch 1 taken 114505 times.
1259555 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
424
425
2/2
✓ Branch 0 taken 1946585 times.
✓ Branch 1 taken 114505 times.
2061090 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
426 //firesfx = 0; //t.b.a -Z
427 114505 isCore = true; //t.b.a
428 114505 parentCore = 0; //t.b.a
429
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
430
431 114505 firesfx = d->firesfx;
432
2/2
✓ Branch 0 taken 3664160 times.
✓ Branch 1 taken 114505 times.
3778665 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
433
2/2
✓ Branch 0 taken 3664160 times.
✓ Branch 1 taken 114505 times.
3778665 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
434
435
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
436
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
437
438
2/2
✓ Branch 0 taken 916040 times.
✓ Branch 1 taken 114505 times.
1030545 for ( int32_t q = 0; q < 8; q++ )
439 {
440 916040 initD[q] = d->initD[q];
441 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
442 916040 weap_initiald[q] = d->weap_initiald[q];
443 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
444 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
445 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
446 916040 }
447
2/2
✓ Branch 0 taken 229010 times.
✓ Branch 1 taken 114505 times.
343515 for ( int32_t q = 0; q < 2; q++ )
448 {
449 229010 initA[q] = d->initA[q];
450 229010 weap_initiala[q] = d->weap_initiala[q];
451 229010 }
452
453 114505 stickclk = 0;
454 114505 submerged = false;
455 114505 didScriptThisFrame = false;
456 114505 ffcactivated = 0;
457 114505 hitdir = -1;
458 114505 dialogue_str = 0; //set by spawn flags.
459 114505 editorflags = d->editorflags; //set by Enemy Editor
460 //Set the drawing flag for this sprite.
461
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
462
463
464
2/2
✓ Branch 0 taken 105647 times.
✓ Branch 1 taken 8858 times.
114505 if(bosspal>-1)
465 {
466
1/2
✓ Branch 0 taken 8858 times.
✗ Branch 1 not taken.
8858 loadpalset(csBOSS,pSprite(bosspal));
467 8858 }
468
469
2/2
✓ Branch 0 taken 49794 times.
✓ Branch 1 taken 64711 times.
114505 if(bgsfx>-1)
470 {
471
1/2
✓ Branch 0 taken 49794 times.
✗ Branch 1 not taken.
49794 cont_sfx(bgsfx);
472 49794 }
473
474
2/2
✓ Branch 0 taken 88380 times.
✓ Branch 1 taken 26125 times.
114505 if(get_qr(qr_NEWENEMYTILES))
475 {
476 88380 o_tile=d->e_tile;
477 88380 frate = d->e_frate;
478 88380 }
479 else
480 {
481 26125 o_tile=d->tile;
482 26125 frate = d->frate;
483 }
484
485 114505 tile=0; //init to 0 here, but set it later.
486
487 114505 scripttile = -1;
488 114505 scriptflip = -1;
489 114505 do_animation = true;
490 114505 immortal = false;
491 114505 noSlide = false;
492 114505 deathexstate = -1;
493
494 114505 hashero=false;
495
496 // If they forgot the invisibility flag, here's another failsafe:
497
4/4
✓ Branch 0 taken 5791 times.
✓ Branch 1 taken 108714 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 5697 times.
114505 if(o_tile==0 && family!=eeSPINTILE)
498 5697 flags |= guy_invisible;
499
500 // step = d->step/100.0;
501 // To preserve the odd step values for Keese & Gleeok heads. -L
502
5/8
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12145 times.
✓ Branch 5 taken 102360 times.
✓ Branch 6 taken 12145 times.
✗ Branch 7 not taken.
114505 if(dstep==62.0) dstep+=0.5;
503
5/8
✓ Branch 0 taken 102360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102360 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 101661 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102360 else if(dstep==89) dstep-=1/9;
504
505
5/10
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114505 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114505 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114505 times.
✗ Branch 9 not taken.
114505 step = zslongToFix(dstep*100);
506
507
508 114505 item_set = d->item_set;
509 114505 grumble = d->grumble;
510
511
2/2
✓ Branch 0 taken 89927 times.
✓ Branch 1 taken 24578 times.
114505 if(frate == 0)
512 24578 frate = 256;
513
514 114505 leader = itemguy = dying = scored = false;
515 114505 canfreeze = count_enemy = true;
516 114505 mainguy = !(flags & guy_doesntcount);
517
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 dir = zc_oldrand()&3;
518
519 //2.6 Enemy Editor Hit and TIle Sizes
520
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114496 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114505 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
521 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
522 // al_trace("Enemy txsz:%i\n", txsz);
523
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114496 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114505 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
524
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114498 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114505 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
525
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114498 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114505 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114505 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114505 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
527
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
528
1/2
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
114505 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
529 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114505 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114505 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114505 times.
114505 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
532 {
533 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
534 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
535 }
536
537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114505 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114505 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
538
539 114505 SIZEflags = d->SIZEflags;
540
541
8/10
✓ Branch 0 taken 114256 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114139 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
114505 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
542 1 wpn = 0;
543
544 //tile should never be 0 after init --Z (failsafe)
545
4/6
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107945 times.
✓ Branch 5 taken 6560 times.
114505 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
546
547 //Moveflags; for gravity and pit interaction
548 114505 moveflags = d->moveflags;
549
3/4
✓ Branch 0 taken 114505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96845 times.
✓ Branch 3 taken 17660 times.
114505 if(!can_pitfall(false))
550 {
551 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
552 17660 moveflags &= ~FLAG_CAN_PITFALL;
553 17660 moveflags &= ~FLAG_CAN_WATERDROWN;
554 17660 }
555
556 114505 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
557 114505 }
558
559 598 int32_t enemy::getScriptUID() { return script_UID; }
560 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
561 114274 enemy::~enemy()
562 114274 {
563
2/4
✓ Branch 0 taken 114274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114274 times.
✗ Branch 3 not taken.
114274 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
564
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114261 times.
114274 if(hashero)
565 {
566
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
567 13 hashero=false;
568 13 }
569 114274 }
570
571
572 bool enemy::is_move_paused()
573 {
574 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
575 }
576
577 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
578 {
579 7024 int32_t yg = (special==spw_floater)?8:0;
580 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
581 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
582
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
583 input_x = dx;
584
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
585 input_y = dy;
586
587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
588
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
589
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
590 return true;
591
592
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
593 {
594 if(ispitfall(dx,dy))
595 return true;
596 }
597
598 7024 bool flying = false;
599 7024 bool cansolid = false;
600
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(moveflags & FLAG_IGNORE_SOLIDITY)
601 cansolid = true;
602
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
603 {
604 case spw_clipbottomright:
605 if(dy>=128 || dx>=208) return true;
606 break;
607 case spw_clipright:
608 break; //if(input_x>=208) return true; break;
609
610 case spw_wizzrobe: // fall through
611 case spw_floater: // Special case for fliers and wizzrobes - hack!
612 {
613
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
614 {
615 if(dy < 32-yg || dy >= 144) return true;
616 if(dx < 32 || dx >= 224) return true;
617 }
618
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
619 return true;
620 317 cansolid = true;
621 317 flying = true;
622 }
623 317 }
624
625 7024 dx &= ~7;
626 7024 dy &= ~7;
627
628
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
629
630
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
631 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
632 //_walkflag code
633 mapscr *s1, *s2;
634 7024 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
635 7024 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
636
637 7024 int32_t cpos=(dx>>4)+(dy&0xF0);
638
3/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1038 times.
✓ Branch 3 taken 5986 times.
7024 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
639 7024 newcombo const& c = combobuf[ci];
640 7024 newcombo const& c1 = combobuf[ci1];
641 7024 newcombo const& c2 = combobuf[ci2];
642
643 7024 int32_t b=1;
644
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
645
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
646
647 #define iwtr(cmb, x, y, shallow) \
648 (shallow \
649 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
650 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
651 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
652 7024 bool wtr = iwtr(ci, dx, dy, false);
653
2/2
✓ Branch 0 taken 3551 times.
✓ Branch 1 taken 3473 times.
7024 bool shwtr = iwtr(ci, dx, dy, true);
654 7024 bool pit = ispitfall(dx,dy);
655
656
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
7024 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
657
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
7024 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
658 7024 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
659 7024 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
660 7024 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
661
662
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
663 {
664 6707 int32_t cwalkflag = c.walk & 0xF;
665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
667 {
668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
669 {
670 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
671 {
672 int efflag = (c1.walk & 0xF0)>>4;
673 int newsolid = (c1.walk & 0xF);
674 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
675 }
676 else cwalkflag &= c1.walk;
677 }
678 6707 else cwalkflag |= c1.walk & 0xF;
679 6707 }
680
2/2
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 721 times.
6707 if (s2)
681 {
682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if (c2.type == cBRIDGE)
683 {
684 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
685 {
686 int efflag = (c2.walk & 0xF0)>>4;
687 int newsolid = (c2.walk & 0xF);
688 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
689 }
690 else cwalkflag &= c2.walk;
691 }
692 721 else cwalkflag |= c2.walk & 0xF;
693 721 }
694
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
695 239 return true;
696 6468 }
697
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
698 {
699 bool ret = true;
700 if (needwtr && wtr) ret = false;
701 else if (needshwtr && shwtr) ret = false;
702 else if (needpit && pit) ret = false;
703 return ret;
704 }
705
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
706 return true;
707
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
708 return true;
709
710 6785 return false;
711 7024 }
712
713 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
714 {
715
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
716 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
717 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
718
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
719 {
720 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
721 return false;
722 }
723
724
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
725
726
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
727 {
728
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
729 {
730
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
731 770 int mx = (bx+dx).getFloor();
732
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
733 {
734
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
735 return false;
736 2976 }
737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
738 return false;
739
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
740 return false;
741 770 }
742 else
743 {
744 341 int mx = (rx+dx).getCeil();
745 341 int lx = mx-hit_width+1;
746
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
747 {
748
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
749 1 return false;
750 2141 }
751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
752 return false;
753
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
754 return false;
755 }
756 1110 }
757
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
758 {
759
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
760 {
761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
762 315 int my = (by+dy).getFloor();
763
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
764 {
765
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
766 238 return false;
767 154 }
768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
769 return false;
770
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
771 return false;
772 77 }
773 else
774 {
775 109 int my = (ry+dy).getCeil();
776 109 int ly = my-hit_height+1;
777
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
778 {
779
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
780 return false;
781 218 }
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
783 return false;
784
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
785 return false;
786 }
787 186 }
788 else //! Untested, and currently unused.
789 {
790 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
791 }
792 1296 return true;
793 1535 }
794
795 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
796 {
797 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
798 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
799
800 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
801
802 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
803 return false;
804 for(zfix ty = 0; by+ty < ry; ty += 8)
805 {
806 for(zfix tx = 0; bx+tx < rx; tx += 8)
807 {
808 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
809 return false;
810 }
811 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
812 return false;
813 }
814 for(zfix tx = 0; bx+tx < rx; tx += 8)
815 {
816 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
817 return false;
818 }
819 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
820 return false;
821 return true;
822 }
823
824 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
825 {
826 auto oxsz = hit_width, oysz = hit_height;
827 if(nwid > -1) hit_width = nwid;
828 if(nhei > -1) hit_height = nhei;
829 bool ret = scr_canplace(dx,dy,special,kb);
830 hit_width = oxsz; hit_height = oysz;
831 return ret;
832 }
833
834 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
835 {
836 1311 bool ret = true;
837
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
838 dy = 0;
839 1311 const int scl = 2;
840
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
841 {
842
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
843 {
844 260 int32_t tdx = dx.sign() * scl;
845
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
846 260 dx -= tdx;
847 else
848 {
849 if(earlyret) return false;
850 dx = tdx;
851 ret = false;
852 }
853 260 }
854 else
855 {
856 34 int32_t tdy = dy.sign() * scl;
857
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
858 27 dy -= tdy;
859 else
860 {
861
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
862 7 dy = tdy;
863 7 ret = false;
864 }
865 }
866 }
867
868
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
869 {
870
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
871 1110 x += dx;
872 else
873 {
874
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
875 ret = false;
876 int xsign = dx.sign();
877 while(scr_canmove(xsign, 0, special, kb, ign_sv))
878 {
879 x += xsign;
880 dx -= xsign;
881 }
882 if(dx)
883 {
884 dx.doDecBound(0,-9999, 0,9999);
885 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
886 if(scr_canmove(val, 0, special, kb, ign_sv))
887 {
888 retval = val;
889 return BSEARCH_CONTINUE_AWAY0;
890 }
891 else return BSEARCH_CONTINUE_TOWARD0;
892 });
893 x += dx;
894 }
895 }
896 1110 }
897
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
898 {
899
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
900 186 y += dy;
901 else
902 {
903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
904 14 ret = false;
905 14 int ysign = dy.sign();
906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
907 {
908 y += ysign;
909 dy -= ysign;
910 }
911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
912 {
913 14 dy.doDecBound(0,-9999, 0,9999);
914
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
916 {
917 retval = val;
918 return BSEARCH_CONTINUE_AWAY0;
919 }
920 210 else return BSEARCH_CONTINUE_TOWARD0;
921 210 });
922 14 y += dy;
923 14 }
924 }
925 200 }
926 1310 return ret;
927 1311 }
928
929 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
930 {
931
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
932
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
933 {
934 case up:
935 return movexy(0, -px, special, kb, false, earlyret);
936 case down:
937 16 return movexy(0, px, special, kb, false, earlyret);
938 case left:
939 479 return movexy(-px, 0, special, kb, false, earlyret);
940 case right:
941 259 return movexy(px, 0, special, kb, false, earlyret);
942 case r_up:
943 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
944 case r_down:
945 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
946 case l_up:
947 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
948 case l_down:
949 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
950 }
951 return false;
952 754 }
953
954 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
955 {
956 double v = degrees.getFloat() * PI / 180.0;
957 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
958 return movexy(dx, dy, special, kb, false, earlyret);
959 }
960
961 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
962 {
963 zfix tx = x, ty = y;
964 bool ret = movexy(dx, dy, special, kb, false, true);
965 x = tx;
966 y = ty;
967 return ret;
968 }
969 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
970 {
971 754 zfix tx = x, ty = y;
972 754 bool ret = moveDir(dir, px, special, kb, true);
973 754 x = tx;
974 754 y = ty;
975 754 return ret;
976 }
977 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
978 {
979 zfix tx = x, ty = y;
980 bool ret = moveAtAngle(degrees, px, special, kb, true);
981 x = tx;
982 y = ty;
983 return ret;
984 }
985
986 // Handle pitfalls
987 37818667 bool enemy::do_falling(int32_t index)
988 {
989
2/2
✓ Branch 0 taken 37816369 times.
✓ Branch 1 taken 2298 times.
37818667 if(fallclk > 0)
990 {
991
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2265 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 20 times.
2298 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
992
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 22 times.
2298 if(!--fallclk)
993 {
994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
995 ++fallclk; //force another frame of falling.... forever.
996
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
997 {
998
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_neverret)
999 never_return(index);
1000
1001
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1002 kill_em_all();
1003
1004 //leave_item(); //Don't drop items in pits!
1005 11 stop_bgsfx(index);
1006 11 return true;
1007 }
1008 else
1009 {
1010 11 try_death(true); //Force death
1011 11 ++fallclk; //force another frame of falling
1012 }
1013 11 }
1014
1015 2287 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1016 2287 cs = spr.csets & 0xF;
1017
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t fr = spr.frames ? spr.frames : 1;
1018
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t spd = spr.speed ? spr.speed : 1;
1019 2287 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1020
2/2
✓ Branch 0 taken 1101 times.
✓ Branch 1 taken 1186 times.
2287 tile = spr.tile + zc_min(animclk / spd, fr-1);
1021 2287 }
1022 37818656 return false;
1023 37818667 }
1024
1025 // Handle drowning in water
1026 37816369 bool enemy::do_drowning(int32_t index)
1027 {
1028
1/2
✓ Branch 0 taken 37816369 times.
✗ Branch 1 not taken.
37816369 if(drownclk > 0)
1029 {
1030 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1031 //!TODO: Drown SFX
1032 if(!--drownclk)
1033 {
1034 if(immortal) //Keep alive forever
1035 ++drownclk; //force another frame of falling.... forever.
1036 else if(dying) //Give 1 frame for script revival
1037 {
1038 if(flags&guy_neverret)
1039 never_return(index);
1040
1041 if(leader)
1042 kill_em_all();
1043
1044 //leave_item(); //Don't drop items in pits!
1045 stop_bgsfx(index);
1046 return true;
1047 }
1048 else
1049 {
1050 try_death(true); //Force death
1051 ++drownclk; //force another frame of falling
1052 }
1053 }
1054
1055 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1056 {
1057 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1058 cs = spr.csets & 0xF;
1059 int32_t fr = spr.frames ? spr.frames : 1;
1060 int32_t spd = spr.speed ? spr.speed : 1;
1061 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1062 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1063 }
1064 else
1065 {
1066 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1067 cs = spr.csets & 0xF;
1068 int32_t fr = spr.frames ? spr.frames : 1;
1069 int32_t spd = spr.speed ? spr.speed : 1;
1070 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1071 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1072 }
1073 }
1074 37816369 return false;
1075 37816369 }
1076
1077 // Supplemental animation code that all derived classes should call
1078 // as a return value for animate().
1079 // Handles the death animation and returns true when enemy is finished.
1080 38480957 bool enemy::Dead(int32_t index)
1081 {
1082
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38479128 times.
38480957 if(immortal)
1083 {
1084 1829 dying = false;
1085 1829 return false;
1086 }
1087
2/2
✓ Branch 0 taken 762799 times.
✓ Branch 1 taken 37716329 times.
38479128 if(dying)
1088 {
1089
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 762798 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
762799 if(deathexstate > -1 && deathexstate < 32)
1090 {
1091 1 setxmapflag(1<<deathexstate);
1092 1 deathexstate = -1;
1093 1 }
1094 762799 --clk2;
1095
1096
4/4
✓ Branch 0 taken 723173 times.
✓ Branch 1 taken 39626 times.
✓ Branch 2 taken 38636 times.
✓ Branch 3 taken 3184 times.
762799 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1097
2/2
✓ Branch 0 taken 41820 times.
✓ Branch 1 taken 681353 times.
723173 && hp>-1000) // not killed by ringleader
1098 38636 death_sfx();
1099
1100
2/2
✓ Branch 0 taken 719433 times.
✓ Branch 1 taken 43366 times.
762799 if(clk2==0)
1101 {
1102
2/2
✓ Branch 0 taken 42662 times.
✓ Branch 1 taken 704 times.
43366 if(flags&guy_neverret)
1103 704 never_return(index);
1104
1105
2/2
✓ Branch 0 taken 43295 times.
✓ Branch 1 taken 71 times.
43366 if(leader)
1106 71 kill_em_all();
1107
1108 43366 leave_item();
1109 43366 }
1110
1111 762799 stop_bgsfx(index);
1112 762799 return (clk2==0);
1113 }
1114
1115 37716329 return false;
1116 38480957 }
1117
1118 // Basic animation code that all derived classes should call.
1119 // The one with an index is the one that is called by
1120 // the guys sprite list; index is the enemy's index in the list.
1121 37818923 bool enemy::animate(int32_t index)
1122 {
1123
2/2
✓ Branch 0 taken 1679486 times.
✓ Branch 1 taken 36139437 times.
37818923 if(sclk <= 0) hitdir = -1;
1124
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37818667 times.
37818923 if(switch_hooked)
1125 {
1126
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1127 {
1128 //Run its script
1129 if (!didScriptThisFrame)
1130 {
1131 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1132 {
1133 return 0; //Avoid NULLPO if this object deleted itself
1134 }
1135 }
1136 }
1137 256 return false;
1138 }
1139
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37818656 times.
37818667 if(do_falling(index)) return true;
1140
2/2
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 37816369 times.
37818656 else if(fallclk)
1141 {
1142 //clks
1143
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 676 times.
2287 if(hclk>0)
1144 676 --hclk;
1145
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(stunclk>0)
1146 --stunclk;
1147
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if ( frozenclock > 0 )
1148 --frozenclock;
1149
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(hashero)
1150 {
1151 Hero.setX(x);
1152 Hero.setY(y);
1153 Hero.fallCombo = fallCombo;
1154 Hero.fallclk = fallclk;
1155 hashero = false; //Let Hero go if falling
1156 }
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2287 times.
2287 if (!didScriptThisFrame)
1158 {
1159 2287 run_script(MODE_NORMAL);
1160 2287 }
1161 2287 return false;
1162 }
1163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37816369 times.
37816369 if(do_drowning(index)) return true;
1164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37816369 times.
37816369 else if(drownclk)
1165 {
1166 //clks
1167 if(hclk>0)
1168 --hclk;
1169 if(stunclk>0)
1170 --stunclk;
1171 if ( frozenclock > 0 )
1172 --frozenclock;
1173 if(hashero)
1174 {
1175 Hero.setX(x);
1176 Hero.setY(y);
1177 Hero.drownclk = drownclk;
1178 hashero = false; //Let Hero go if falling
1179 }
1180 if (!didScriptThisFrame)
1181 {
1182 run_script(MODE_NORMAL);
1183 }
1184 return false;
1185 }
1186 37816369 int32_t nx = real_x(x);
1187 37816369 int32_t ny = real_y(y);
1188
1189
4/4
✓ Branch 0 taken 27351064 times.
✓ Branch 1 taken 10465305 times.
✓ Branch 2 taken 5642996 times.
✓ Branch 3 taken 21708068 times.
37816369 if(ox!=nx || oy!=ny)
1190 {
1191 16108301 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1192 16108301 }
1193
1194 37816369 ox = nx;
1195 37816369 oy = ny;
1196
1197 // Maybe they fell off the bottom in sideview, or were moved by a script.
1198
1199 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1200
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37814540 times.
37816369 if ( immortal )
1201 {
1202 //skip, as it can go out of bounds, from immortality
1203 1829 }
1204
2/6
✓ Branch 0 taken 37814540 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37814540 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37814540 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1205 {
1206 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1207 }
1208
9/10
✓ Branch 0 taken 37418447 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 37813535 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 37783644 times.
✓ Branch 5 taken 29891 times.
✓ Branch 6 taken 37783644 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 37783593 times.
37814540 else if ( (OUTOFBOUNDS) )
1209 {
1210 30947 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1211 30947 }
1212 //fall down
1213
6/6
✓ Branch 0 taken 27135246 times.
✓ Branch 1 taken 10681123 times.
✓ Branch 2 taken 10413563 times.
✓ Branch 3 taken 27402806 times.
✓ Branch 4 taken 506182 times.
✓ Branch 5 taken 9907381 times.
37816369 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 9603807 times.
9907381 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1220 {
1221 127235 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 127235 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 127235 y+=fall/100;
1242
2/2
✓ Branch 0 taken 109427 times.
✓ Branch 1 taken 17808 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1243 109427 fall += (zinit.gravity/100);
1244 }
1245 127235 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 267 do_fix(y, 8); //Fix position
1252 267 }
1253
1254 176339 fall = 0;
1255 }
1256 303574 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= (int32_t)zinit.terminalv)
1287 fall += (zinit.gravity/100);
1288 }
1289 }
1290 303574 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9603807 times.
9603807 if (!(moveflags & FLAG_NO_FAKE_Z))
1294 {
1295
2/2
✓ Branch 0 taken 5054760 times.
✓ Branch 1 taken 4549047 times.
9603807 if(fakefall!=0)
1296 4549047 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 4549047 times.
✓ Branch 1 taken 5054760 times.
9603807 if(fakez<0)
1299 4549047 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5054760 times.
5054760 else if(fakefall <= (int32_t)zinit.terminalv)
1301 5054760 fakefall += (zinit.gravity/100);
1302
1303
5/6
✓ Branch 0 taken 9603807 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5054760 times.
✓ Branch 3 taken 4549047 times.
✓ Branch 4 taken 4563262 times.
✓ Branch 5 taken 491498 times.
9603807 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 9603807 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9603807 times.
9603807 if (!(moveflags & FLAG_NO_REAL_Z))
1306 {
1307
2/2
✓ Branch 0 taken 5472506 times.
✓ Branch 1 taken 4131301 times.
9603807 if(fall!=0)
1308 4131301 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 4118019 times.
✓ Branch 1 taken 5485788 times.
9603807 if(z<0)
1311 4118019 z = fall = 0;
1312
2/2
✓ Branch 0 taken 9167 times.
✓ Branch 1 taken 5476621 times.
5485788 else if(fall <= (int32_t)zinit.terminalv)
1313 5476621 fall += (zinit.gravity/100);
1314
1315
6/6
✓ Branch 0 taken 9562903 times.
✓ Branch 1 taken 40904 times.
✓ Branch 2 taken 5444884 times.
✓ Branch 3 taken 4118019 times.
✓ Branch 4 taken 4955193 times.
✓ Branch 5 taken 489691 times.
9603807 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 9603807 }
1317
1318 }
1319 9907381 }
1320
4/4
✓ Branch 0 taken 37420276 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 11935005 times.
✓ Branch 3 taken 27376833 times.
37816369 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
1321 {
1322
8/10
✓ Branch 0 taken 9160893 times.
✓ Branch 1 taken 18215940 times.
✓ Branch 2 taken 9121235 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9121235 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9160893 times.
✓ Branch 8 taken 9121235 times.
✓ Branch 9 taken 9121235 times.
27376833 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1323 {
1324 9121235 fallCombo = check_pits();
1325 9121235 }
1326 45619303 }
1327
4/4
✓ Branch 0 taken 37420276 times.
✓ Branch 1 taken 15901755 times.
✓ Branch 2 taken 36998321 times.
✓ Branch 3 taken 421955 times.
21518521 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
1328 {
1329
8/10
✓ Branch 0 taken 142669 times.
✓ Branch 1 taken 279286 times.
✓ Branch 2 taken 141616 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141616 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142669 times.
✓ Branch 8 taken 141616 times.
✓ Branch 9 taken 141616 times.
421955 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1330 {
1331 141616 drownCombo = check_water();
1332 141616 }
1333 705187 }
1334
1335 53046691 runKnockback(); //scripted knockback handling
1336
1337 // clk is incremented here
1338
2/2
✓ Branch 0 taken 50742024 times.
✓ Branch 1 taken 2304667 times.
53046691 if(++clk >= frate)
1339 2304667 clk=0;
1340
1341 // hit and death handling
1342
2/2
✓ Branch 0 taken 51807270 times.
✓ Branch 1 taken 1239421 times.
53046691 if(hclk>0)
1343 1239421 --hclk;
1344
1345
2/2
✓ Branch 0 taken 52370375 times.
✓ Branch 1 taken 676316 times.
53046691 if(stunclk>0)
1346 676316 --stunclk;
1347
1/2
✓ Branch 0 taken 53046691 times.
✗ Branch 1 not taken.
53046691 if ( frozenclock > 0 )
1348 --frozenclock;
1349
1350
5/6
✓ Branch 0 taken 13488 times.
✓ Branch 1 taken 53033203 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 13382 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
53046691 if(ceiling && z <= 0 && fakez <= 0)
1351 106 ceiling = false;
1352
1353 53046691 try_death();
1354
1355 53046691 scored=false;
1356
1357 53046691 ++c_clk;
1358
1359 //Run its script
1360
2/2
✓ Branch 0 taken 15260083 times.
✓ Branch 1 taken 37786608 times.
53046691 if (!didScriptThisFrame)
1361 {
1362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37786608 times.
37786608 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1363 {
1364 return 0; //Avoid NULLPO if this object deleted itself
1365 }
1366 37786608 }
1367
1368 // returns true when enemy is defeated
1369 53046691 return Dead(index);
1370 53049245 }
1371
1372 38570818 bool enemy::setSolid(bool set)
1373 {
1374
1/2
✓ Branch 0 taken 38570818 times.
✗ Branch 1 not taken.
38570818 bool actual = set && !isSubmerged();
1375 38570818 bool ret = solid_object::setSolid(actual);
1376 38570818 solid = set;
1377 38570818 return ret;
1378 }
1379 void enemy::doContactDamage(int32_t hdir)
1380 {
1381 Hero.hithero(guys.find(this), hdir);
1382 }
1383
1384 22405 void enemy::solid_push(solid_object *obj)
1385 {
1386
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
1388 22405 zfix dx, dy;
1389 22405 int32_t hdir = -1;
1390 22405 solid_push_int(obj,dx,dy,hdir,true);
1391
1392
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 22142 times.
✓ Branch 3 taken 150 times.
22405 if(!dx && !dy) return;
1393
1394 263 bool t = obj->getTempNonsolid();
1395 263 obj->setTempNonsolid(true);
1396
1397 263 int32_t ydir = dy > 0 ? down : up;
1398 263 int32_t xdir = dx > 0 ? right : left;
1399
1400 263 auto special = isflier(id) ? spw_floater : spw_none;
1401
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1402 {
1403 //Crushed?
1404 7 }
1405
1406 263 obj->setTempNonsolid(t);
1407 22405 }
1408 22405 bool enemy::is_unpushable() const
1409 {
1410 22405 return isSubmerged();
1411 }
1412 22087 bool enemy::sideview_mode() const
1413 {
1414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
1415 }
1416
1417 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1418 {
1419 3234 int32_t yg = (special==spw_floater)?8:0;
1420 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1421
1422
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1423 4732 return true;
1424
1425 3238 bool isInDungeon = isdungeon();
1426
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1427 {
1428
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1429 1199 return true;
1430
1431
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1432
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1433 return true;
1434 595 }
1435
1436
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
1437 {
1438
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1439
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1440 return true;
1441 62 }
1442
1443
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1444 {
1445 case spw_clipbottomright:
1446 if(dy>=128 || dx>=208) return true;
1447 break;
1448 case spw_clipright:
1449 break; //if(x>=208) return true; break;
1450
1451 case spw_wizzrobe: // fall through
1452 case spw_floater: // Special case for fliers and wizzrobes - hack!
1453 {
1454
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1455 {
1456
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1457
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1458 595 }
1459 857 return false;
1460 }
1461 }
1462
1463 dx&=(special==spw_halfstep)?(~7):(~15);
1464 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1465
1466 if(special==spw_water)
1467 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1468
1469 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1470 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1471 870 }
1472
1473 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1474 {
1475 6575 bool kb = false;
1476 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1477
1478
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1479 return true;
1480
1481
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon())
1482 {
1483
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=144))
1484 return true;
1485
1486
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=224))
1487 return true;
1488 1513 }
1489
1490
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
1491 {
1492
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1493
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1494 return true;
1495 6575 }
1496
1497
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1498 {
1499
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1501 }
1502 else
1503 {
1504
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1505
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1506
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1508 }
1509 6575 }
1510
1511 32455765 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1512 {
1513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32455765 times.
32455765 if(moveflags & FLAG_USE_NEW_MOVEMENT)
1514 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1515 32455765 int32_t yg = (special==spw_floater)?8:0;
1516 32455765 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1517
2/2
✓ Branch 0 taken 3703972 times.
✓ Branch 1 taken 28751793 times.
32455765 switch(dir)
1518 {
1519 case l_down:
1520 case r_down:
1521 case down:
1522 case 11: //r_down
1523 case 12: //down
1524 case 13: //l_down
1525 {
1526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3703972 times.
3703972 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1527 {
1528
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3703964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3703972 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1529 {
1530 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1531
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1532 8 }
1533 3703972 }
1534 3703972 break;
1535 }
1536 }
1537
2/2
✓ Branch 0 taken 3704791 times.
✓ Branch 1 taken 28750974 times.
32455765 switch(dir)
1538 {
1539 case r_up:
1540 case r_down:
1541 case right:
1542 case 9: //r_up
1543 case 10: //right
1544 case 11: //r_down
1545 {
1546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704791 times.
3704791 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1547 {
1548
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3704788 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3704791 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1549 {
1550 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1551
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1552 3 }
1553 3704791 }
1554 3704791 break;
1555 }
1556 }
1557 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1558
1559
10/10
✓ Branch 0 taken 22401718 times.
✓ Branch 1 taken 10054047 times.
✓ Branch 2 taken 8752429 times.
✓ Branch 3 taken 1301618 times.
✓ Branch 4 taken 10016968 times.
✓ Branch 5 taken 37079 times.
✓ Branch 6 taken 9993841 times.
✓ Branch 7 taken 23127 times.
✓ Branch 8 taken 22454590 times.
✓ Branch 9 taken 32448431 times.
32455765 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1560 44916514 return true;
1561
1562 32448431 bool isInDungeon = isdungeon();
1563
4/4
✓ Branch 0 taken 3927169 times.
✓ Branch 1 taken 28521262 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3915413 times.
32448431 if(isInDungeon || special==spw_wizzrobe)
1564 {
1565
8/8
✓ Branch 0 taken 5892093 times.
✓ Branch 1 taken 22640925 times.
✓ Branch 2 taken 5667626 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820209 times.
✓ Branch 5 taken 17045183 times.
✓ Branch 6 taken 5820022 times.
✓ Branch 7 taken 187 times.
28533018 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1566 11487648 return true;
1567
1568
8/8
✓ Branch 0 taken 5739730 times.
✓ Branch 1 taken 11305640 times.
✓ Branch 2 taken 5573275 times.
✓ Branch 3 taken 166455 times.
✓ Branch 4 taken 5688191 times.
✓ Branch 5 taken 5783904 times.
✓ Branch 6 taken 5687237 times.
✓ Branch 7 taken 954 times.
17045370 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1569
2/2
✓ Branch 0 taken 113868 times.
✓ Branch 1 taken 94 times.
11260512 if(special!=spw_door) // walk in door way
1570 113868 return true;
1571 5784952 }
1572
1573
6/6
✓ Branch 0 taken 3100399 times.
✓ Branch 1 taken 6599966 times.
✓ Branch 2 taken 750062 times.
✓ Branch 3 taken 2350337 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 698832 times.
9700365 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
1574 {
1575
4/4
✓ Branch 0 taken 3042752 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3041800 times.
6091019 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1576
4/4
✓ Branch 0 taken 3042569 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3041850 times.
✓ Branch 3 taken 719 times.
3042752 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1577 7369 return true;
1578 3041800 }
1579
1580
4/4
✓ Branch 0 taken 7508153 times.
✓ Branch 1 taken 2178589 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9692996 switch(special)
1581 {
1582 case spw_clipbottomright:
1583
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=128 || dx>=208) return true;
1584 707 break;
1585 case spw_clipright:
1586 5281 break; //if(input_x>=208) return true; break;
1587
1588 case spw_wizzrobe: // fall through
1589 case spw_floater: // Special case for fliers and wizzrobes - hack!
1590 {
1591
2/2
✓ Branch 0 taken 2866474 times.
✓ Branch 1 taken 4641679 times.
7508153 if(isInDungeon)
1592 {
1593
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= 144) return true;
1594
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= 224) return true;
1595 4639539 }
1596 7506013 return false;
1597 }
1598 }
1599
1600 2184577 dx&=(special==spw_halfstep)?(~7):(~15);
1601
2/2
✓ Branch 0 taken 486587 times.
✓ Branch 1 taken 1697990 times.
2184577 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1602
1603
2/2
✓ Branch 0 taken 414391 times.
✓ Branch 1 taken 1770186 times.
2184577 if(special==spw_water)
1604
2/2
✓ Branch 0 taken 16741 times.
✓ Branch 1 taken 397650 times.
414391 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1605
1606
2/2
✓ Branch 0 taken 1711259 times.
✓ Branch 1 taken 58927 times.
1770186 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1607 {
1608
4/4
✓ Branch 0 taken 1227868 times.
✓ Branch 1 taken 483391 times.
✓ Branch 2 taken 1217831 times.
✓ Branch 3 taken 10037 times.
2929090 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203251 times.
1217831 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1610 }
1611 else
1612 {
1613
4/4
✓ Branch 0 taken 42434 times.
✓ Branch 1 taken 16493 times.
✓ Branch 2 taken 42170 times.
✓ Branch 3 taken 264 times.
101097 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1614
3/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 41807 times.
✗ Branch 3 not taken.
42170 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1615
4/4
✓ Branch 0 taken 36572 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 36557 times.
✓ Branch 3 taken 15 times.
41807 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1616
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 36254 times.
36557 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1617 }
1618 10079707 }
1619
1620 383430 bool enemy::isOnSideviewPlatform()
1621 {
1622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1624
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383430 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1625 return false;
1626
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1628
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1629 {
1630
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1631
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1633 47357 }
1634 168001 return false;
1635 383430 }
1636
1637 // Stops playing the given sound only if there are no enemies left to play it
1638 765710 void enemy::stop_bgsfx(int32_t index)
1639 {
1640
2/2
✓ Branch 0 taken 750600 times.
✓ Branch 1 taken 15110 times.
765710 if(bgsfx<=0)
1641 750600 return;
1642
1643 // Look for other enemies with the same bgsfx
1644
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1645 {
1646
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1647 6304 return;
1648 46690 }
1649
1650 8806 stop_sfx(bgsfx);
1651 765710 }
1652
1653
1654 // to allow for different sfx on defeating enemy
1655 40244 void enemy::death_sfx()
1656 {
1657
2/2
✓ Branch 0 taken 39960 times.
✓ Branch 1 taken 284 times.
40244 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1658 40244 }
1659
1660 void enemy::move(zfix dx,zfix dy)
1661 {
1662 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1663 {
1664 switch(family)
1665 {
1666 case eeFIRE:
1667 case eeOTHER:
1668 return;
1669 default: break;
1670 }
1671 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1672 }
1673 */
1674 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
1675 {
1676 x+=dx;
1677 y+=dy;
1678 }
1679 }
1680
1681 18327343 void enemy::move(zfix s)
1682 {
1683 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1684 {
1685 switch(family)
1686 {
1687 case eeFIRE:
1688 case eeOTHER:
1689 return;
1690 default: break;
1691 }
1692 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1693 }*/
1694
9/10
✓ Branch 0 taken 18327304 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 18247542 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
18327343 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
1695 {
1696 18326449 sprite::move(s);
1697 18326449 }
1698 18327343 }
1699
1700 43668 void enemy::leave_item()
1701 {
1702 43668 int32_t drop_item = select_dropitem(item_set, x, y);
1703 43668 int32_t thedropset = item_set;
1704
1705 43668 std::vector<int32_t> &ev = FFCore.eventData;
1706 43668 ev.clear();
1707 43668 ev.push_back(getUID());
1708 43668 ev.push_back(drop_item*10000);
1709 43668 ev.push_back(thedropset*10000);
1710
1711 43668 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1712 43668 drop_item = vbound(ev[1] / 10000,-2,255);
1713 43668 thedropset = ev[2] / 10000;
1714 43668 ev.clear();
1715
1/2
✓ Branch 0 taken 43668 times.
✗ Branch 1 not taken.
43668 if(drop_item == -2)
1716 {
1717 drop_item = select_dropitem(thedropset,x,y);
1718 }
1719
1720
6/6
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 27239 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15512 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43668 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1721 {
1722 item* itm;
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16260 times.
16260 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1724 {
1725 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1726 }
1727 else
1728 {
1729
8/14
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 14631 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1629 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1629 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1629 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1629 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1629 times.
✗ Branch 13 not taken.
16260 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1730
4/8
✓ Branch 0 taken 14631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14631 times.
✗ Branch 7 not taken.
14631 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1731 }
1732 16260 itm->from_dropset = thedropset;
1733 16260 items.add(itm);
1734
1735 16260 ev.push_back(getUID());
1736 16260 ev.push_back(itm->getUID());
1737
1738 16260 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1739 16260 ev.clear();
1740 16260 }
1741 43668 }
1742
1743 // auomatically kill off enemy (for rooms with ringleaders)
1744 397 void enemy::kickbucket()
1745 {
1746
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 32 times.
397 if(!superman)
1747 365 hp=-1000; // don't call death_sfx()
1748 397 }
1749
1750 21250 bool enemy::isSubmerged() const
1751 {
1752 21250 return submerged;
1753 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1754 }
1755
1756 20952 void enemy::FireBreath(bool seekhero)
1757 {
1758
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1759 return;
1760
1761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1762 {
1763 dmisc1 = e1tEACHTILE;
1764 FireWeapon();
1765 return;
1766 }
1767
1768 20952 float fire_angle=0.0;
1769 20952 int32_t wx=0, wy=0, wdir=dir;
1770
1771
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1772 {
1773
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1774 {
1775 case down:
1776 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1777 3079 wx=x;
1778 3079 wy=y+8;
1779 3079 break;
1780
1781 case -1:
1782 case up:
1783 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1784 3297 wx=x;
1785 3297 wy=y-8;
1786 3297 break;
1787
1788 case left:
1789 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1790 5287 wx=x-8;
1791 5287 wy=y;
1792 5287 break;
1793
1794 case right:
1795 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1796 4208 wx=x+8;
1797 4208 wy=y;
1798 4208 break;
1799 }
1800
1801
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1802 {
1803
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1809
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1810
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1811 15735 }
1812 15871 }
1813 else
1814 {
1815 5081 wx = x;
1816 5081 wy = y;
1817 }
1818
1819
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1820 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1821
1822 20952 int32_t i=Ewpns.Count()-1;
1823 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1824 20952 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1825
1826
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1827 {
1828 7957 ew->angular=true;
1829 7957 ew->angle=fire_angle;
1830 7957 }
1831
1832
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1833 {
1834 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1836 20359 }
1837
1838
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1839 {
1840 766199 Ewpns.swap(j,j-1);
1841 766199 }
1842 20952 }
1843
1844 44653 void enemy::FireWeapon()
1845 {
1846 /*
1847 * Type:
1848 * 0x01: Boss fireball
1849 * 0x02: Seeks Hero
1850 * 0x04: Fast projectile
1851 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1852 */
1853
1854
2/2
✓ Branch 0 taken 44522 times.
✓ Branch 1 taken 131 times.
44653 if (wpn < 1) return;
1855
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44522 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1856 return;
1857
1858
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44522 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1859 dmisc1 = e1tEACHTILE;
1860
1861 44522 int32_t xoff = 0;
1862 44522 int32_t yoff = 0;
1863
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1864 {
1865 xoff += (hit_width/2)-8;
1866 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1867 }
1868
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1869 {
1870 yoff += (hit_height/2)-8;
1871 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1872 }
1873
1874
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41523 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44522 switch(dmisc1)
1875 {
1876 case e1t5SHOTS: //BS-Aquamentus
1877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1879 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1880 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1881
1882 [[fallthrough]];
1883 case e1t3SHOTSFAST:
1884 case e1t3SHOTS: //Aquamentus
1885
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1886 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1888 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1889
1890 [[fallthrough]];
1891 default:
1892
12/20
✓ Branch 0 taken 42169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42169 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42169 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42169 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42164 times.
✓ Branch 12 taken 42169 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23931 times.
✓ Branch 16 taken 42169 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42169 times.
✗ Branch 19 not taken.
42169 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1893 42169 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1894 42169 sfx(wpnsfx(wpn),pan(int32_t(x)));
1895 42169 break;
1896
1897 case e1tSLANT:
1898 {
1899 416 int32_t slant = 0;
1900
1901
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1902 246 slant = left;
1903
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1904 117 slant = right;
1905
1906
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1907 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1908 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1909 330 break;
1910 }
1911
1912 case e1t8SHOTS: //Fire Wizzrobe
1913
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1916
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1919
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1922
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1923 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1924 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1925
1926 [[fallthrough]];
1927 case e1t4SHOTS: //Stalfos 3
1928
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1930 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1931
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1933 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1934
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1937
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1938 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1939 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1940 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1941 1937 break;
1942
1943 case e1tSUMMON: // Bat Wizzrobe
1944 {
1945 //al_trace("Summon Bats\n");
1946 //zprint2("Summon Bats\n");
1947 if(dmisc4==0) break; // Summon 0
1948
1949 int32_t bc=0;
1950
1951 for(int32_t gc=0; gc<guys.Count(); gc++)
1952 {
1953 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1954 {
1955 ++bc;
1956 }
1957 }
1958
1959 if(bc<=40) // Not too many enemies
1960 {
1961 int32_t kids = guys.Count();
1962 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1963
1964 for(int32_t i=0; i<bats; i++)
1965 {
1966 //zprint2("summon\n");
1967 //al_trace("summon\n");
1968 if(addchild(x,y,dmisc3,-10, this->script_UID))
1969 {
1970 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1971 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
1972 //zprint2("Summoner Script UID: %d\n",this->script_UID);
1973
1974 }
1975 }
1976
1977 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1978 }
1979
1980 break;
1981 }
1982
1983 case e1tSUMMONLAYER: // Summoner
1984 {
1985 if(count_layer_enemies()==0)
1986 {
1987 break;
1988 }
1989
1990 int32_t kids = guys.Count();
1991
1992 if(kids<40)
1993 {
1994 int32_t newguys=(zc_oldrand()%3)+1;
1995 bool summoned=false;
1996
1997 for(int32_t i=0; i<newguys; i++)
1998 {
1999 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
2000 int32_t x2=0;
2001 int32_t y2=0;
2002
2003 for(int32_t k=0; k<20; ++k)
2004 {
2005 x2=16*((zc_oldrand()%12)+2);
2006 y2=16*((zc_oldrand()%7)+2);
2007
2008 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2009 {
2010 //zprint2("summon\n");
2011 //al_trace("summon\n");
2012 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2013 {
2014 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2015 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
2016 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
2017 {
2018 ((enemy*)guys.spr(kids+i))->fakez = 64;
2019 ((enemy*)guys.spr(kids+i))->z = 0;
2020 }
2021 }
2022
2023 summoned=true;
2024 break;
2025 }
2026 }
2027 }
2028
2029 if(summoned)
2030 {
2031 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2032 }
2033 }
2034
2035 break;
2036 }
2037 }
2038 44567 }
2039
2040
2041 // Hit the shield(s)?
2042 // Apparently, this function is only used for hookshots...
2043 2741 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2044 {
2045
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1765 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2741 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2046 834 return false;
2047
2048 1907 bool ret = false;
2049
2050 // TODO: There must be some bitwise operations that can simplify this...
2051
9/12
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1907 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
2052
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 798 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 798 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 13 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1181 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
2053
2054
11/14
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 1065 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✓ Branch 12 taken 840 times.
✗ Branch 13 not taken.
1933 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
2055
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
2056
2057 1933 return ret;
2058 2767 }
2059
2060
2061 //! Weapon Editor for 2.6
2062 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2063
2064
2065 //converts a wqeapon ID to its defence index.
2066 126800 int32_t weaponToDefence(int32_t wid)
2067 {
2068
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64360 times.
✓ Branch 2 taken 9432 times.
✓ Branch 3 taken 25029 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3146 times.
✓ Branch 9 taken 9834 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1217 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2036 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 26 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
126800 switch(wid)
2069 {
2070 case wNone: return -1;
2071 64360 case wSword: return edefSWORD;
2072 9432 case wBeam: return edefBEAM;
2073 25029 case wBrang: return edefBRANG;
2074 4207 case wBomb: return edefBOMB;
2075 37 case wSBomb: return edefSBOMB;
2076 48 case wLitBomb: return edefBOMB;
2077 case wLitSBomb: return edefSBOMB;
2078 3146 case wArrow: return edefARROW;
2079 9834 case wFire: return edefFIRE;
2080 case wWhistle:
2081 {
2082 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
2083 return edefWhistle;
2084 }
2085 case wBait: return edefBAIT;
2086 269 case wWand: return edefWAND;
2087 1217 case wMagic: return edefMAGIC;
2088 case wCatching: return -1;
2089 case wWind: return edefWIND;
2090 512 case wRefMagic: return edefREFMAGIC;
2091 1459 case wRefFireball: return edefREFBALL;
2092 case wRefRock: return edefREFROCK;
2093 2036 case wHammer: return edefHAMMER;
2094 2767 case wHookshot: return edefHOOKSHOT;
2095 610 case wHSHandle: return edefHOOKSHOT;
2096 case wHSChain: return edefHOOKSHOT;
2097 240 case wSSparkle: return edefSPARKLE;
2098 469 case wFSparkle: return edefSPARKLE;
2099 case wSmack: return -1; // is this the candle object?
2100 case wPhantom: return -1; //engine created visual effects.
2101 case wCByrna: return edefBYRNA;
2102 19 case wRefBeam: return edefREFBEAM;
2103 case wStomp: return edefSTOMP;
2104 26 case wScript1: return edefSCRIPT01;
2105 case wScript2: return edefSCRIPT02;
2106 12 case wScript3: return edefSCRIPT03;
2107 77 case wScript4: return edefSCRIPT04;
2108 case wScript5: return edefSCRIPT05;
2109 case wScript6: return edefSCRIPT06;
2110 case wScript7: return edefSCRIPT07;
2111 case wScript8: return edefSCRIPT08;
2112 case wScript9: return edefSCRIPT09;
2113 993 case wScript10: return edefSCRIPT10;
2114 case wIce: return edefICE;
2115 case wSound: return edefSONIC;
2116 1 case wThrown: return edefTHROWN;
2117 case wRefArrow: return edefREFARROW;
2118 case wRefFire: return edefREFFIRE;
2119 case wRefFire2: return edefREFFIRE2;
2120 //case wPot: return edefPOT;
2121 // case wLitZap: return edefELECTRIC;
2122 // case wZ3Sword: return edefZ3SWORD;
2123 // case wLASWord: return edefLASWORD;
2124 // case wSpinAttk: return edefSPINATTK;
2125 // case wShield: return edefSHIELD;
2126 // case wTrowel: return edefTROWEL;
2127
2128 default: return -1;
2129 }
2130 126800 }
2131
2132 126800 int32_t getDefType(weapon *w)
2133 {
2134 126800 int32_t id = getWeaponID(w);
2135 126800 int32_t edef = weaponToDefence(id);
2136
2/2
✓ Branch 0 taken 123423 times.
✓ Branch 1 taken 3377 times.
126800 if(edef == edefHOOKSHOT)
2137 {
2138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2139 return edefSwitchHook;
2140 3377 }
2141 126800 return edef;
2142 126800 }
2143
2144 225804 int32_t getWeaponID(weapon *w)
2145 {
2146 225804 int32_t usewpn = w->useweapon;
2147
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 225574 times.
225804 return (usewpn > 0) ? usewpn : w->id;
2148 }
2149
2150 126800 int32_t enemy::resolveEnemyDefence(weapon *w)
2151 {
2152 //sword edef is 9, but we're reading it at 0
2153 //,
2154 126800 int32_t weapondef = 0;
2155 126800 int32_t wdeftype = getDefType(w);
2156 126800 int32_t usedef = w->usedefence;
2157
2158
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
126800 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2159 {
2160 weapondef = usedef*-1;
2161 }
2162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126800 times.
126800 else if(unsigned(wdeftype) < edefLAST255)
2163 {
2164 126800 weapondef = wdeftype;
2165 126800 }
2166 126800 return weapondef;
2167 }
2168
2169 137335 byte get_def_ignrflag(int32_t edef)
2170 {
2171
3/3
✓ Branch 0 taken 114424 times.
✓ Branch 1 taken 3649 times.
✓ Branch 2 taken 19262 times.
137335 switch(edef)
2172 {
2173 case edIGNORE:
2174 case edIGNOREL1:
2175 case edSTUNORIGNORE:
2176 19262 return WPNUNB_IGNR;
2177 case edSTUNORCHINK:
2178 case edCHINK:
2179 case edCHINKL1:
2180 case edCHINKL2:
2181 case edCHINKL4:
2182 case edCHINKL6:
2183 case edCHINKL8:
2184 case edCHINKL10:
2185 case edLEVELCHINK2:
2186 case edLEVELCHINK3:
2187 case edLEVELCHINK4:
2188 case edLEVELCHINK5:
2189 3649 return WPNUNB_BLOCK;
2190 }
2191 114424 return 0;
2192 137335 }
2193
2194 137335 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2195 {
2196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137335 times.
137335 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2197 switch(edef)
2198 {
2199 case edIGNORE:
2200 case edIGNOREL1:
2201 case edCHINK:
2202 case edCHINKL1:
2203 case edCHINKL2:
2204 case edCHINKL4:
2205 case edCHINKL6:
2206 case edCHINKL8:
2207 case edCHINKL10:
2208 case edLEVELCHINK2:
2209 case edLEVELCHINK3:
2210 case edLEVELCHINK4:
2211 case edLEVELCHINK5:
2212 return edNORMAL;
2213 case edSTUNORIGNORE:
2214 case edSTUNORCHINK:
2215 return edSTUNONLY;
2216 }
2217 return edef;
2218 137335 }
2219
2220 // Do we do damage?
2221 // 0: takehit returns 0
2222 // 1: takehit returns 1
2223 // -1: do damage
2224 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2225 125807 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2226 {
2227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125807 times.
125807 if(switch_hooked) return 0;
2228 125807 int32_t tempx = x;
2229 125807 int32_t tempy = y;
2230 125807 int32_t the_defence = 0;
2231
1/2
✓ Branch 0 taken 125807 times.
✗ Branch 1 not taken.
125807 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2232 {
2233 the_defence = edef*-1; //A specific defence type.
2234 }
2235 125807 else the_defence = defense[edef];
2236
2237 125807 the_defence = conv_edef_unblockable(the_defence, unblockable);
2238
2239
3/4
✓ Branch 0 taken 6557 times.
✓ Branch 1 taken 119250 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6557 times.
125807 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2240 {
2241
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6550 times.
✓ Branch 2 taken 7 times.
6557 switch(the_defence)
2242 {
2243 case edIGNORE:
2244 7 return 0;
2245 case edIGNOREL1:
2246 case edSTUNORIGNORE:
2247 if(*power <= 0)
2248 return 0;
2249 }
2250 6550 sfx(WAV_CHINK,pan(int32_t(x)));
2251 6550 return 1;
2252 }
2253
2254 119250 int32_t new_id = id;
2255 119250 int32_t effect_type = dmisc15;
2256 119250 int32_t delay_timer = 90;
2257 119250 enemy *gleeok = NULL;
2258 119250 enemy *ptra = NULL;
2259 119250 int32_t c = 0;
2260
2261
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 915 times.
✓ Branch 13 taken 17324 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2179 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93040 times.
119250 switch(the_defence)
2262 {
2263 case edREPLACE:
2264 {
2265 sclk = 0;
2266 if ( dmisc16 > 0 ) new_id = dmisc16;
2267 else new_id = id+1;
2268 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2269 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2270 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2271
2272 //Z_scripterrlog("new id is %d\n", new_id);
2273 switch(guysbuf[new_id&0xFFF].family)
2274 {
2275 //Fixme: possible enemy memory leak. (minor)
2276 case eeWALK:
2277 {
2278 enemy *e = new eStalfos(x,y,new_id,clk);
2279 guys.add(e);
2280 }
2281 break;
2282
2283 case eeLEV:
2284 {
2285 enemy *e = new eLeever(x,y,new_id,clk);
2286 guys.add(e);
2287 }
2288 break;
2289
2290 case eeTEK:
2291 {
2292 enemy *e = new eTektite(x,y,new_id,clk);
2293 guys.add(e);
2294 }
2295 break;
2296
2297 case eePEAHAT:
2298 {
2299 enemy *e = new ePeahat(x,y,new_id,clk);
2300 guys.add(e);
2301 }
2302 break;
2303
2304 case eeZORA:
2305 {
2306 enemy *e = new eZora(x,y,new_id,clk);
2307 guys.add(e);
2308 }
2309 break;
2310
2311 case eeGHINI:
2312 {
2313 enemy *e = new eGhini(x,y,new_id,clk);
2314 guys.add(e);
2315 }
2316 break;
2317
2318 case eeKEESE:
2319 {
2320 enemy *e = new eKeese(x,y,new_id,clk);
2321 guys.add(e);
2322 }
2323 break;
2324
2325 case eeWIZZ:
2326 {
2327 enemy *e = new eWizzrobe(x,y,new_id,clk);
2328 guys.add(e);
2329 }
2330 break;
2331
2332 case eePROJECTILE:
2333 {
2334 enemy *e = new eProjectile(x,y,new_id,clk);
2335 guys.add(e);
2336 }
2337 break;
2338
2339 case eeWALLM:
2340 {
2341 enemy *e = new eWallM(x,y,new_id,clk);
2342 guys.add(e);
2343 }
2344 break;
2345
2346 case eeAQUA:
2347 {
2348 enemy *e = new eAquamentus(x,y,new_id,clk);
2349 guys.add(e);
2350 e->x = x;
2351 e->y = y;
2352 }
2353 break;
2354
2355 case eeMOLD:
2356 {
2357 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
2358 guys.add(e);
2359 e->x = x;
2360 e->y = y;
2361 }
2362 break;
2363
2364 case eeMANHAN:
2365 {
2366 enemy *e = new eManhandla(x,y,new_id,clk);
2367 guys.add(e);
2368 e->x = x;
2369 e->y = y;
2370 }
2371 break;
2372
2373 case eeGLEEOK:
2374 {
2375 *power = 0;
2376 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
2377 guys.add(gleeok);
2378 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2379 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2380 new_id &= 0xFFF;
2381 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2382 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2383 for(int32_t i=0; i<head_cnt; i++)
2384 {
2385 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2386 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2387 {
2388 al_trace("Gleeok head %d could not be created!\n",i+1);
2389
2390 for(int32_t j=0; j<i+1; j++)
2391 {
2392 guys.del(guys.Count()-1);
2393 }
2394
2395 break;
2396 }
2397 else
2398 {
2399 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2400 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2401 }
2402
2403 c-=guysbuf[new_id].misc4;
2404 //gleeok->x = x;
2405 //gleeok->y = y;
2406 //gleeok = e;
2407 }
2408 return 1;
2409 }
2410
2411 case eeGHOMA:
2412 {
2413 enemy *e = new eGohma(x,y,new_id,clk);
2414 guys.add(e);
2415 e->x = x;
2416 e->y = y;
2417 }
2418 break;
2419
2420 case eeLANM:
2421 {
2422 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
2423 guys.add(e);
2424 e->x = x;
2425 e->y = y;
2426 }
2427 break;
2428
2429 case eeGANON:
2430 {
2431 enemy *e = new eGanon(x,y,new_id,clk);
2432 guys.add(e);
2433 e->x = x;
2434 e->y = y;
2435 }
2436 break;
2437
2438 case eeFAIRY:
2439 {
2440 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2441 guys.add(e);
2442 e->x = x;
2443 e->y = y;
2444 }
2445 break;
2446
2447 case eeFIRE:
2448 {
2449 enemy *e = new eFire(x,y,new_id,clk);
2450 guys.add(e);
2451 e->x = x;
2452 e->y = y;
2453 }
2454 break;
2455
2456 case eeOTHER:
2457 {
2458 enemy *e = new eOther(x,y,new_id,clk);
2459 guys.add(e);
2460 e->x = x;
2461 e->y = y;
2462 }
2463 break;
2464
2465 case eeSPINTILE:
2466 {
2467 enemy *e = new eSpinTile(x,y,new_id,clk);
2468 guys.add(e);
2469 e->x = x;
2470 e->y = y;
2471 }
2472 break;
2473
2474 // and these enemies use the misc10/misc2 value
2475 case eeROCK:
2476 {
2477 switch(guysbuf[new_id&0xFFF].misc10)
2478 {
2479 case 1:
2480 {
2481 enemy *e = new eBoulder(x,y,new_id,clk);
2482 guys.add(e);
2483 e->x = x;
2484 e->y = y;
2485 }
2486 break;
2487
2488 case 0:
2489 default:
2490 {
2491 enemy *e = new eRock(x,y,new_id,clk);
2492 guys.add(e);
2493 e->x = x;
2494 e->y = y;
2495 }
2496 break;
2497 }
2498
2499 break;
2500 }
2501
2502 case eeTRAP:
2503 {
2504 switch(guysbuf[new_id&0xFFF].misc2)
2505 {
2506 case 1:
2507 {
2508 enemy *e = new eTrap2(x,y,new_id,clk);
2509 guys.add(e);
2510 e->x = x;
2511 e->y = y;
2512 }
2513 break;
2514
2515 case 0:
2516 default:
2517 {
2518 enemy *e = new eTrap(x,y,new_id,clk);
2519 guys.add(e);
2520 e->x = x;
2521 e->y = y;
2522 }
2523 break;
2524 }
2525
2526 break;
2527 }
2528
2529 case eeDONGO:
2530 {
2531 switch(guysbuf[new_id&0xFFF].misc10)
2532 {
2533 case 1:
2534 {
2535 enemy *e = new eDodongo2(x,y,new_id,clk);
2536 guys.add(e);
2537 e->x = x;
2538 e->y = y;
2539 }
2540 break;
2541
2542 case 0:
2543 default:
2544 {
2545 enemy *e = new eDodongo(x,y,new_id,clk);
2546 guys.add(e);
2547 e->x = x;
2548 e->y = y;
2549 }
2550 break;
2551 }
2552
2553 break;
2554 }
2555
2556 case eeDIG:
2557 {
2558 switch(guysbuf[new_id&0xFFF].misc10)
2559 {
2560 case 1:
2561 {
2562 enemy *e = new eLilDig(x,y,new_id,clk);
2563 guys.add(e);
2564 e->x = x;
2565 e->y = y;
2566 }
2567 break;
2568
2569 case 0:
2570 default:
2571 {
2572 enemy *e = new eBigDig(x,y,new_id,clk);
2573 guys.add(e);
2574 e->x = x;
2575 e->y = y;
2576 }
2577 break;
2578 }
2579
2580 break;
2581 }
2582
2583 case eePATRA:
2584 {
2585 switch(guysbuf[new_id&0xFFF].misc10)
2586 {
2587 case 1:
2588 {
2589 if (get_qr(qr_HARDCODED_BS_PATRA))
2590 {
2591 enemy *e = new ePatraBS(x,y,new_id,clk);
2592 guys.add(e);
2593 e->x = x;
2594 e->y = y;
2595 break;
2596 }
2597 }
2598 [[fallthrough]];
2599 case 0:
2600 default:
2601 {
2602 enemy *e = new ePatra(x,y,new_id,clk);
2603 guys.add(e);
2604 e->x = x;
2605 e->y = y;
2606 }
2607 break;
2608 }
2609
2610 break;
2611 }
2612
2613 case eeGUY:
2614 {
2615 switch(guysbuf[new_id&0xFFF].misc10)
2616 {
2617 case 1:
2618 {
2619 enemy *e = new eTrigger(x,y,new_id,clk);
2620 guys.add(e);
2621 }
2622 break;
2623
2624 case 0:
2625 default:
2626 {
2627 enemy *e = new eNPC(x,y,new_id,clk);
2628 guys.add(e);
2629 }
2630 break;
2631 }
2632
2633 break;
2634 }
2635
2636 case eeSCRIPT01:
2637 case eeSCRIPT02:
2638 case eeSCRIPT03:
2639 case eeSCRIPT04:
2640 case eeSCRIPT05:
2641 case eeSCRIPT06:
2642 case eeSCRIPT07:
2643 case eeSCRIPT08:
2644 case eeSCRIPT09:
2645 case eeSCRIPT10:
2646 case eeSCRIPT11:
2647 case eeSCRIPT12:
2648 case eeSCRIPT13:
2649 case eeSCRIPT14:
2650 case eeSCRIPT15:
2651 case eeSCRIPT16:
2652 case eeSCRIPT17:
2653 case eeSCRIPT18:
2654 case eeSCRIPT19:
2655 case eeSCRIPT20:
2656 {
2657 enemy *e = new eScript(x,y,new_id,clk);
2658 guys.add(e);
2659 e->x = x;
2660 e->y = y;
2661 break;
2662 }
2663
2664
2665 case eeFFRIENDLY01:
2666 case eeFFRIENDLY02:
2667 case eeFFRIENDLY03:
2668 case eeFFRIENDLY04:
2669 case eeFFRIENDLY05:
2670 case eeFFRIENDLY06:
2671 case eeFFRIENDLY07:
2672 case eeFFRIENDLY08:
2673 case eeFFRIENDLY09:
2674 case eeFFRIENDLY10:
2675 {
2676 enemy *e = new eFriendly(x,y,new_id,clk);
2677 guys.add(e);
2678 e->x = x;
2679 e->y = y;
2680 break;
2681 }
2682
2683
2684 default: break;
2685 }
2686
2687 // add segments of segmented enemies
2688 int32_t c=0;
2689
2690 switch(guysbuf[new_id&0xFFF].family)
2691 {
2692 case eeMOLD:
2693 {
2694 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2695 new_id &= 0xFFF;
2696
2697 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
2698 {
2699 //christ this is messy -DD
2700 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2701
2702 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2703 {
2704 al_trace("Moldorm segment %d could not be created!\n",i+1);
2705
2706 for(int32_t j=0; j<i+1; j++)
2707 guys.del(guys.Count()-1);
2708
2709 return 0;
2710 }
2711
2712 if(i>0)
2713 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2714
2715
2716 }
2717
2718 break;
2719 }
2720
2721 case eeLANM:
2722 {
2723 new_id &= 0xFFF;
2724 int32_t shft = guysbuf[new_id].misc2;
2725 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2726 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2727
2728 if(!guys.add(e))
2729 {
2730 al_trace("Lanmola segment 1 could not be created!\n");
2731 guys.del(guys.Count()-1);
2732 return 0;
2733 }
2734 e->x = x;
2735 e->y = y;
2736
2737
2738
2739 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
2740 {
2741 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2742 if(!guys.add(e2))
2743 {
2744 al_trace("Lanmola segment %d could not be created!\n",i+1);
2745
2746 for(int32_t j=0; j<i+1; j++)
2747 guys.del(guys.Count()-1);
2748
2749 return 0;
2750 }
2751 e2->x = x;
2752 e2->y = y;
2753
2754 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2755
2756 }
2757 }
2758 break;
2759
2760 case eeMANHAN:
2761 new_id &= 0xFFF;
2762
2763 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
2764 {
2765 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2766 {
2767 al_trace("Manhandla head %d could not be created!\n",i+1);
2768
2769 for(int32_t j=0; j<i+1; j++)
2770 {
2771 guys.del(guys.Count()-1);
2772 }
2773
2774 return 0;
2775 }
2776
2777
2778 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
2779 }
2780
2781 break;
2782
2783 case eeGLEEOK:
2784 {
2785 /*
2786 new_id &= 0xFFF;
2787 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2788 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2789 for(int32_t i=0; i<head_cnt; i++)
2790 {
2791 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2792 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2793 {
2794 al_trace("Gleeok head %d could not be created!\n",i+1);
2795
2796 for(int32_t j=0; j<i+1; j++)
2797 {
2798 guys.del(guys.Count()-1);
2799 }
2800
2801 break;
2802 }
2803
2804 c-=guysbuf[new_id].misc4;
2805 */
2806
2807 // }
2808 }
2809 break;
2810
2811
2812 case eePATRA:
2813 {
2814 new_id &= 0xFFF;
2815 int32_t outeyes = 0;
2816 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2817
2818 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
2819 {
2820 if(!((guysbuf[new_id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2821 {
2822 al_trace("Patra outer eye %d could not be created!\n",i+1);
2823
2824 for(int32_t j=0; j<i+1; j++)
2825 guys.del(guys.Count()-1);
2826
2827 return 0;
2828 }
2829 else
2830 outeyes++;
2831
2832
2833 }
2834
2835 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
2836 {
2837 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2838 {
2839 al_trace("Patra inner eye %d could not be created!\n",i+1);
2840
2841 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2842 guys.del(guys.Count()-1);
2843
2844 return 0;
2845 }
2846
2847
2848 }
2849 delete ptra;
2850 break;
2851 }
2852 }
2853
2854
2855
2856 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2857 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2858 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2859 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2860 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2861 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2862 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2863 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
2864 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2865 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2866 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2867 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2868 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2869 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2870
2871
2872 item_set = 0; //Do not make a drop.
2873
2874 switch(effect_type)
2875 {
2876 case -7:
2877 {
2878 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2879 Lwpns.add(w);
2880 break;
2881 }
2882 case -6:
2883 {
2884 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2885 Lwpns.add(w);
2886 break;
2887 }
2888 case -5:
2889 {
2890 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2891 Lwpns.add(w);
2892 break;
2893 }
2894 case -4:
2895 {
2896 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2897 Lwpns.add(w);
2898 break;
2899 }
2900 case -3: explode(1); break;
2901 case -2: explode(2); break;
2902 case -1: explode(0); break;
2903 case 0: break;
2904
2905 default:
2906 {
2907 //Dummy weapon function
2908 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2909 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2910 Lwpns.add(w);
2911 break;
2912 }
2913 }
2914
2915
2916 yofs = -32768;
2917 switch(guysbuf[new_id&0xFFF].family)
2918 {
2919 case eeGLEEOK:
2920 {
2921 Z_scripterrlog("Replacing a gleeok.\n");
2922 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2923 hp = -999;
2924 tempenemy->hp = -999;
2925 break;
2926
2927 }
2928 default:
2929 hp = -1000; break;
2930 }
2931 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2932 return 1;
2933
2934 }
2935 case edSPLIT:
2936 {
2937 //int32_t ex = x; int32_t ey = y;
2938 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2939 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2940 /*
2941 if ( txsx > 1 )
2942 {
2943 ex += ( txsz-1 ) * 8; //from its middle
2944 }
2945 if ( tysx > 1 )
2946 {
2947 ey += ( tysz-1 ) * 8; //from its middle
2948 }
2949 */
2950 for ( int32_t q = 0; q < dmisc4; q++ )
2951 {
2952
2953 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
2954 addenemy(
2955 //ex,ey,
2956 x,y,
2957 dmisc3+0x1000,-15);
2958 //addenemy(ex,ey,dmisc3,0);
2959
2960 }
2961 item_set = 0; //Do not make a drop.
2962 hp = -1000;
2963 return -1;
2964
2965 }
2966 case edSUMMON:
2967 {
2968
2969
2970 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2971 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2972 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2973 for ( int32_t q = 0; q < summon_count; q++ )
2974 {
2975 int32_t x2=16*((zc_oldrand()%12)+2);
2976 int32_t y2=16*((zc_oldrand()%7)+2);
2977 addenemy(
2978 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2979 x2,y2,
2980 dmisc3+0x1000,-15);
2981 //addenemy(ex,ey,dmisc3,0);
2982
2983 }
2984 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2985 return -1;
2986
2987 }
2988
2989 case edEXPLODESMALL:
2990 {
2991 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2992 Ewpns.add(ew);
2993 item_set = 0; //Should we make a drop?
2994 hp = -1000;
2995 return -1;
2996 }
2997
2998
2999 case edEXPLODEHARMLESS:
3000 {
3001 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3002 Ewpns.add(ew);
3003 ew->hyofs = -32768;
3004 item_set = 0; //Should we make a drop?
3005 hp = -1000;
3006 return -1;
3007 }
3008
3009
3010 case edEXPLODELARGE:
3011 {
3012 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3013 Ewpns.add(ew);
3014
3015 hp = -1000;
3016 return -1;
3017 }
3018
3019
3020 case edTRIGGERSECRETS:
3021 {
3022 hidden_entrance(0, true, false, -4);
3023 return -1;
3024 }
3025
3026 case edSTUNORCHINK:
3027
3/4
✓ Branch 0 taken 1123 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1123 times.
✗ Branch 3 not taken.
3709 if (stunclk && get_qr(qr_NO_STUNLOCK))
3028 {
3029 sfx(WAV_CHINK,pan(int32_t(x)));
3030 return 1;
3031 }
3032
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1530 times.
2179 else if(*power <= 0)
3033 {
3034 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
3035 649 sfx(WAV_CHINK,pan(int32_t(x)));
3036 649 return 1;
3037 }
3038 [[fallthrough]];
3039
3040 case edSTUNORIGNORE:
3041
3/4
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1956 times.
✗ Branch 3 not taken.
5967 if (stunclk && get_qr(qr_NO_STUNLOCK))
3042 {
3043 sfx(WAV_CHINK,pan(int32_t(x)));
3044 return 1;
3045 }
3046
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2506 times.
3461 else if(*power <= 0)
3047 955 return 0;
3048 [[fallthrough]];
3049
3050 case edSTUNONLY:
3051
7/10
✓ Branch 0 taken 4368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3821 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4047 times.
✓ Branch 9 taken 321 times.
4368 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3052 {
3053 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3054 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3055 321 return 1;
3056 }
3057
3/4
✓ Branch 0 taken 3122 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3122 times.
✗ Branch 3 not taken.
4047 if (stunclk && get_qr(qr_NO_STUNLOCK))
3058 {
3059 sfx(WAV_CHINK,pan(int32_t(x)));
3060 return 1;
3061 }
3062 else
3063 {
3064 4047 stunclk=160;
3065 4047 sfx(WAV_EHIT,pan(int32_t(x)));
3066
3067 4047 return 1;
3068 }
3069
3070 case edCHINKL1:
3071 if(*power >= 1*game->get_hero_dmgmult()) break;
3072 [[fallthrough]];
3073 case edCHINKL2:
3074
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3075 [[fallthrough]];
3076 case edCHINKL4:
3077
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3078 [[fallthrough]];
3079 case edCHINKL6:
3080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3081 [[fallthrough]];
3082 case edCHINKL8:
3083
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3084 [[fallthrough]];
3085 case edCHINKL10:
3086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3087 [[fallthrough]];
3088 case edCHINK:
3089 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
3090 1026 sfx(WAV_CHINK,pan(int32_t(x)));
3091 1026 return 1;
3092
3093 case edIGNOREL1:
3094 if(*power > 0) break;
3095 [[fallthrough]];
3096
3097 case edIGNORE:
3098 17324 return 0;
3099
3100 case ed1HKO:
3101 492 *power = hp;
3102 492 return -2;
3103
3104 case ed2x:
3105 {
3106
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3107 //int32_t pow = *power;
3108 //*power = vbound((pow*2),0,214747);
3109 71 return -1;
3110 }
3111 case ed3x:
3112 {
3113 *power = zc_max(1,*power*3);
3114 //int32_t pow = *power;
3115 //*power = vbound((pow*3),0,214747);
3116 return -1;
3117 }
3118
3119 case ed4x:
3120 {
3121 *power = zc_max(1,*power*4);
3122 //int32_t pow = *power;
3123 //*power = vbound((pow*4),0,214747);
3124 return -1;
3125 }
3126
3127
3128 case edHEAL:
3129 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3130 //int32_t pow = *power;
3131 //*power = vbound((pow*-1),0,214747);
3132 //break;
3133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3134 158 return -1;
3135 }
3136 /*
3137 case edLEVELDAMAGE:
3138 {
3139 int32_t pow = *power;
3140 int32_t lvl = *level;
3141 *power = vbound((pow*lvl),0,214747);
3142 break;
3143 }
3144 case edLEVELREDUCTION:
3145 {
3146 int32_t pow = *power;
3147 int32_t lvl = *level;
3148 *power = vbound((pow/lvl),0,214747);
3149 break;
3150 }
3151 */
3152
3153 case edQUARTDAMAGE:
3154
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3155
3156 [[fallthrough]];
3157 case edHALFDAMAGE:
3158
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3159 988 break;
3160
3161 case edSWITCH:
3162 {
3163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3165 {
3166 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3167 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3168 return 0;
3169 }
3170 4 hooked_combopos = -1;
3171 4 hooked_layerbits = 0;
3172 4 switching_object = this;
3173 4 switch_hooked = true;
3174 4 Hero.doSwitchHook(game->get_switchhookstyle());
3175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3176 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3177 4 return 1;
3178 }
3179
3180 case 0:
3181 {
3182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93040 times.
93040 if(edef == edefSwitchHook)
3183 return -1;
3184
6/6
✓ Branch 0 taken 19536 times.
✓ Branch 1 taken 73504 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19478 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93040 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3185 {
3186 26 sfx(WAV_CHINK,pan(int32_t(x)));
3187 26 return 1;
3188 }
3189
3190 }
3191 93014 }
3192
3193 94177 return -1;
3194 125807 }
3195
3196 125807 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3197 {
3198
1/2
✓ Branch 0 taken 125807 times.
✗ Branch 1 not taken.
125807 int wuid = w?w->getUID():0;
3199
1/2
✓ Branch 0 taken 125807 times.
✗ Branch 1 not taken.
125807 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3200
3201
1/2
✓ Branch 0 taken 125807 times.
✗ Branch 1 not taken.
125807 if(fakeweap)
3202 Lwpns.add(w);
3203 125807 std::vector<int32_t> &ev = FFCore.eventData;
3204 125807 ev.clear();
3205 125807 ev.push_back(*power*10000);
3206 125807 ev.push_back(edef*10000);
3207 125807 ev.push_back(unblockable*10000);
3208 125807 ev.push_back(wpnId*10000);
3209 125807 ev.push_back(0);
3210 125807 ev.push_back(getUID());
3211 125807 ev.push_back(wuid);
3212
3213 125807 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3214 125807 *power = ev[0]/10000;
3215 125807 edef = ev[1]/10000;
3216 125807 unblockable = byte(ev[2]/10000);
3217 125807 wpnId = ev[3] / 10000;
3218 125807 bool nullify = ev[4]!=0;
3219 125807 ev.clear();
3220 125807 int ret = 0;
3221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125807 times.
125807 if(!nullify)
3222 {
3223 125807 ret = defendNew(wpnId, power, edef, unblockable);
3224
2/2
✓ Branch 0 taken 32763 times.
✓ Branch 1 taken 93044 times.
125807 if(ret == -1)
3225 {
3226 93044 ev.push_back(*power*10000);
3227 93044 ev.push_back(edef*10000);
3228 93044 ev.push_back(unblockable*10000);
3229 93044 ev.push_back(wpnId*10000);
3230 93044 ev.push_back(0);
3231 93044 ev.push_back(getUID());
3232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93044 times.
93044 ev.push_back(w?w->getUID():0);
3233
3234 93044 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3235 93044 *power = ev[0]/10000;
3236 93044 nullify = ev[4]!=0;
3237 93044 ev.clear();
3238 93044 }
3239 125807 }
3240
1/2
✓ Branch 0 taken 125807 times.
✗ Branch 1 not taken.
125807 if(fakeweap)
3241 Lwpns.remove(w);
3242
3243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125807 times.
125807 return nullify ? 0 : ret;
3244 }
3245
3246 99004 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3247 {
3248
2/2
✓ Branch 0 taken 98427 times.
✓ Branch 1 taken 577 times.
99004 if(!realweap) realweap = w;
3249 99004 int32_t wid = getWeaponID(w);
3250
3251 99004 int32_t edef = resolveEnemyDefence(w);
3252
2/2
✓ Branch 0 taken 5821 times.
✓ Branch 1 taken 93183 times.
99004 if(QHeader.zelda_version > 0x250)
3253 5821 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3254
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92190 times.
✗ Branch 2 not taken.
93183 switch(wid)
3255 {
3256 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3257 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3258 993 return defend(wpnId, power, edefSCRIPT);
3259
3260 case wWhistle:
3261 return -1;
3262
3263 default:
3264 92190 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3265 }
3266 99004 }
3267
3268
3269 // Check defenses without actually acting on them.
3270 27424 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3271 {
3272
4/10
✓ Branch 0 taken 15431 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27424 switch(defense[edef])
3273 {
3274 case edSTUNONLY:
3275 474 return false;
3276 case edSTUNORCHINK:
3277 case edCHINK:
3278 15431 return unblockable&WPNUNB_BLOCK;
3279 case edSTUNORIGNORE:
3280 case edIGNORE:
3281 11050 return unblockable&WPNUNB_IGNR;
3282
3283 case edIGNOREL1:
3284 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3285 case edCHINKL1:
3286 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3287
3288 case edCHINKL2:
3289 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3290
3291 case edCHINKL4:
3292 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3293
3294 case edCHINKL6:
3295 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3296
3297 case edCHINKL8:
3298 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3299 }
3300
3301 469 return true;
3302 27424 }
3303
3304 // Do we do damage?
3305 // 0: takehit returns 0
3306 // 1: takehit returns 1
3307 // -1: do damage
3308 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3309 {
3310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3311 {
3312 switch(defense[edef])
3313 {
3314 case edIGNORE:
3315 return 0;
3316 case edIGNOREL1:
3317 case edSTUNORIGNORE:
3318 if(*power <= 0)
3319 return 0;
3320 }
3321
3322 sfx(WAV_CHINK,pan(int32_t(x)));
3323 return 1;
3324 }
3325
3326
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3327 {
3328 case edSTUNORCHINK:
3329 if(*power <= 0)
3330 {
3331 sfx(WAV_CHINK,pan(int32_t(x)));
3332 return 1;
3333 }
3334
3335 [[fallthrough]];
3336 case edSTUNORIGNORE:
3337 if(*power <= 0)
3338 return 0;
3339
3340 [[fallthrough]];
3341 case edSTUNONLY:
3342 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3343 return 1;
3344
3345 stunclk=160;
3346 sfx(WAV_EHIT,pan(int32_t(x)));
3347 return 1;
3348
3349 case edFREEZE:
3350 frozenclock=-1;
3351 //sfx(WAV_FREEZE,pan(int32_t(x)));
3352 return 1;
3353
3354 case edCHINKL1:
3355 if(*power >= 1*game->get_hero_dmgmult()) break;
3356 [[fallthrough]];
3357 case edCHINKL2:
3358 if(*power >= 2*game->get_hero_dmgmult()) break;
3359 [[fallthrough]];
3360 case edCHINKL4:
3361 if(*power >= 4*game->get_hero_dmgmult()) break;
3362 [[fallthrough]];
3363 case edCHINKL6:
3364 if(*power >= 6*game->get_hero_dmgmult()) break;
3365 [[fallthrough]];
3366 case edCHINKL8:
3367 if(*power >= 8*game->get_hero_dmgmult()) break;
3368 [[fallthrough]];
3369 case edCHINKL10:
3370 if(*power >= 10*game->get_hero_dmgmult()) break;
3371 [[fallthrough]];
3372 case edCHINK:
3373 sfx(WAV_CHINK,pan(int32_t(x)));
3374 return 1;
3375 case edTRIGGERSECRETS:
3376 hidden_entrance(0, true, false, -4);
3377 break;
3378
3379 case edIGNOREL1:
3380 if(*power > 0) break;
3381 [[fallthrough]];
3382 case edIGNORE:
3383 800 return 0;
3384
3385 case ed1HKO:
3386 *power = hp;
3387 return -2;
3388
3389 case ed2x:
3390 {
3391 *power = zc_max(1,*power*2);
3392 //int32_t pow = *power;
3393 //*power = vbound((pow*2),0,214747);
3394 return -1;
3395 }
3396 case ed3x:
3397 {
3398 *power = zc_max(1,*power*3);
3399 //int32_t pow = *power;
3400 //*power = vbound((pow*3),0,214747);
3401 return -1;
3402 }
3403
3404 case ed4x:
3405 {
3406 *power = zc_max(1,*power*4);
3407 //int32_t pow = *power;
3408 //*power = vbound((pow*4),0,214747);
3409 return -1;
3410 }
3411
3412
3413 case edHEAL:
3414 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3415 //int32_t pow = *power;
3416 //*power = vbound((pow*-1),0,214747);
3417 //break;
3418 *power = zc_min(0,*power*-1);
3419 return -1;
3420 }
3421 /*
3422 case edLEVELDAMAGE:
3423 {
3424 int32_t pow = *power;
3425 int32_t lvl = *level;
3426 *power = vbound((pow*lvl),0,214747);
3427 break;
3428 }
3429 case edLEVELREDUCTION:
3430 {
3431 int32_t pow = *power;
3432 int32_t lvl = *level;
3433 *power = vbound((pow/lvl),0,214747);
3434 break;
3435 }
3436 */
3437
3438
3439 case edQUARTDAMAGE:
3440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3441
3442 [[fallthrough]];
3443 case edHALFDAMAGE:
3444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3445 7 break;
3446 }
3447
3448 193 return -1;
3449 993 }
3450
3451 // Defend against a particular item class.
3452 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3453 {
3454 int32_t def=-1;
3455
3456 switch(wpnId)
3457 {
3458 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3459 case wBrang:
3460 def = defend(wpnId, power, edefBRANG);
3461 break;
3462
3463 case wHookshot:
3464 def = defend(wpnId, power, edefHOOKSHOT);
3465 break;
3466
3467 // Anyway...
3468 case wBomb:
3469 def = defend(wpnId, power, edefBOMB);
3470 break;
3471
3472 case wSBomb:
3473 def = defend(wpnId, power, edefSBOMB);
3474 break;
3475
3476 case wArrow:
3477 def = defend(wpnId, power, edefARROW);
3478 break;
3479
3480 case wFire:
3481 def = defend(wpnId, power, edefFIRE);
3482 break;
3483
3484 case wWand:
3485 def = defend(wpnId, power, edefWAND);
3486 break;
3487
3488 case wMagic:
3489 def = defend(wpnId, power, edefMAGIC);
3490 break;
3491
3492 case wHammer:
3493 def = defend(wpnId, power, edefHAMMER);
3494 break;
3495
3496 case wSword:
3497 def = defend(wpnId, power, edefSWORD);
3498 break;
3499
3500 case wBeam:
3501 def = defend(wpnId, power, edefBEAM);
3502 break;
3503
3504 case wRefBeam:
3505 def = defend(wpnId, power, edefREFBEAM);
3506 break;
3507
3508 case wRefMagic:
3509 def = defend(wpnId, power, edefREFMAGIC);
3510 break;
3511
3512 case wRefFireball:
3513 def = defend(wpnId, power, edefREFBALL);
3514 break;
3515
3516 case wRefRock:
3517 def = defend(wpnId, power, edefREFROCK);
3518 break;
3519
3520 case wStomp:
3521 def = defend(wpnId, power, edefSTOMP);
3522 break;
3523
3524 case wCByrna:
3525 def = defend(wpnId, power, edefBYRNA);
3526 break;
3527
3528 case wScript1:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript2:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript3:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript4:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wScript5:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3550 else def = defend(wpnId, power, edefSCRIPT);
3551 break;
3552
3553 case wScript6:
3554 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3555 else def = defend(wpnId, power, edefSCRIPT);
3556 break;
3557
3558 case wScript7:
3559 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3560 else def = defend(wpnId, power, edefSCRIPT);
3561 break;
3562
3563 case wScript8:
3564 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3565 else def = defend(wpnId, power, edefSCRIPT);
3566 break;
3567
3568 case wScript9:
3569 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3570 else def = defend(wpnId, power, edefSCRIPT);
3571 break;
3572
3573 case wScript10:
3574 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3575 else def = defend(wpnId, power, edefSCRIPT);
3576 break;
3577
3578 case wWhistle:
3579 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3580 else break;
3581 break;
3582
3583 case wRefArrow:
3584 def = defend(wpnId, power, edefREFARROW);
3585 break;
3586 case wRefFire:
3587 def = defend(wpnId, power, edefREFFIRE);
3588 break;
3589 case wRefFire2:
3590 def = defend(wpnId, power, edefREFFIRE2);
3591 break;
3592
3593 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3594 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3595 //of the ten if the quest version is lower than N.
3596 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3597 //such as bool UseSeparatedScriptDefences. hah.
3598 default:
3599 //if(wpnId>=wScript1 && wpnId<=wScript10)
3600 // {
3601 // def = defend(wpnId, power, edefSCRIPT);
3602 // }
3603 // }
3604
3605 break;
3606 }
3607
3608 return def;
3609 }
3610
3611 // take damage or ignore it
3612 // -1: damage (if any) dealt
3613 // 1: blocked
3614 // 0: weapon passes through unhindered
3615 264438 int32_t enemy::takehit(weapon *w, weapon* realweap)
3616 {
3617
2/4
✓ Branch 0 taken 264438 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264438 times.
264438 if(fallclk||drownclk) return 0;
3618
2/2
✓ Branch 0 taken 69344 times.
✓ Branch 1 taken 195094 times.
264438 if(!realweap) realweap = w;
3619 264438 int32_t wpnId = w->id;
3620 264438 int32_t power = w->power;
3621 264438 int32_t wpnx = w->x;
3622 264438 int32_t wpny = w->y;
3623 264438 int32_t enemyHitWeapon = w->parentitem;
3624 int32_t wpnDir;
3625 264438 int32_t parent_item = w->parentitem;
3626
3627
2/2
✓ Branch 0 taken 264323 times.
✓ Branch 1 taken 115 times.
264438 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3628 {
3629 115 wpnId = w->useweapon;
3630 115 }
3631
3632 // If it's a boomerang that just bounced, use the opposite direction;
3633 // otherwise, it might bypass a shield. This probably won't handle
3634 // every case correctly, but it's better than having shields simply
3635 // not work against boomerangs.
3636
8/8
✓ Branch 0 taken 25075 times.
✓ Branch 1 taken 239363 times.
✓ Branch 2 taken 15575 times.
✓ Branch 3 taken 9500 times.
✓ Branch 4 taken 14357 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3305 times.
✓ Branch 7 taken 11052 times.
264438 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3637 11052 wpnDir = oppositeDir[w->dir];
3638 else
3639 253386 wpnDir = w->dir;
3640
3641
5/8
✓ Branch 0 taken 264438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264438 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264438 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8172 times.
✓ Branch 7 taken 271896 times.
264438 if(dying || clk<0 || hclk>0 || superman)
3642 8172 return 0;
3643
3644 //Prevent boomerang from writing to hitby[] for more than one frame.
3645 //This also prevents stunlock.
3646 //if ( stunclk > 0 ) return 0;
3647 //this needs a rule for boomerangs that cannot stunlock!
3648 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3649 //sigh.
3650
3651 271896 int32_t ret = -1;
3652
3653 // This obscure quest rule...
3654
5/6
✓ Branch 0 taken 91656 times.
✓ Branch 1 taken 180240 times.
✓ Branch 2 taken 88153 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88153 times.
271896 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3655 {
3656 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3657 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3658 3503 wpnDir=zc_oldrand()&3;
3659
3660
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3661 {
3662 189 wpnDir=down;
3663 189 }
3664
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3665 {
3666 285 wpnDir=right;
3667 285 }
3668
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3669 {
3670 2064 wpnDir=up;
3671 2064 }
3672 else
3673 {
3674 965 wpnDir=left;
3675 }
3676 3503 }
3677
3678 271896 int32_t xdir = dir;
3679 271896 shieldCanBlock=false;
3680
3681 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
3682
4/4
✓ Branch 0 taken 260616 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 257849 times.
272691 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3683
10/10
✓ Branch 0 taken 18240 times.
✓ Branch 1 taken 15473 times.
✓ Branch 2 taken 25948 times.
✓ Branch 3 taken 247374 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 247316 times.
✓ Branch 6 taken 984 times.
✓ Branch 7 taken 246332 times.
✓ Branch 8 taken 795 times.
✓ Branch 9 taken 245537 times.
260616 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
3684 )
3685 // The hammer should already be dealt with by subclasses (Walker etc.)
3686 {
3687
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5748 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 1488 times.
46025 switch(wpnId)
3688 {
3689 // Weapons which shields protect against
3690 case wSword:
3691 case wWand:
3692
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5746 times.
5750 if(Hero.getCharging()>0)
3693 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3694
3695 [[fallthrough]];
3696 case wHookshot:
3697 case wHSHandle:
3698 case wBrang:
3699 6120 shieldCanBlock=true;
3700 6458 break;
3701
3702 case wBeam:
3703 case wRefBeam:
3704 // Mirror shielded enemies!
3705 #if 0
3706 if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3707 {
3708 if(wpnId>wEnemyWeapons)
3709 return 0;
3710
3711 sfx(WAV_CHINK,pan(int32_t(x)));
3712 return 1;
3713 }
3714
3715 #endif
3716
3717 [[fallthrough]];
3718 case wRefRock:
3719 case wRefFireball:
3720 case wMagic:
3721 #if 0
3722 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3723 {
3724 sfx(WAV_CHINK,pan(int32_t(x)));
3725 return 3;
3726 }
3727
3728 #endif
3729
3730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(wpnId>wEnemyWeapons)
3731 return 0;
3732
3733 [[fallthrough]];
3734 case wArrow:
3735 380 case wRefArrow:
3736 default:
3737 1868 shieldCanBlock=true;
3738 1868 break;
3739
3740 // Bombs
3741 case wSBomb:
3742 case wBomb:
3743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3744 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3745 {
3746 sfx(WAV_CHINK,pan(int32_t(x)));
3747 return 0;
3748 }
3749 else break;
3750
3751 // Weapons which ignore shields
3752 case wWhistle:
3753 case wHammer:
3754 2 break;
3755
3756 // Weapons which shouldn't be removed by shields
3757 case wLitBomb:
3758 case wLitSBomb:
3759 case wWind:
3760 case wPhantom:
3761 case wSSparkle:
3762 case wBait:
3763 864 return 0;
3764
3765 case wFire:
3766 case wRefFire:
3767 case wRefFire2:
3768 ;
3769 680 }
3770 8670 }
3771
3772
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 97347 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27424 times.
✓ Branch 5 taken 25029 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
265487 switch(wpnId)
3773 {
3774 case wWhistle: //No longer completely ignore whistle weapons! -Z
3775 {
3776
3777
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3778 {
3779 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
3780 423 return 0; break;
3781 }
3782 else
3783 {
3784 w->power = power = itemsbuf[parent_item].misc5;
3785
3786 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3787
3788 if(def <= 0)
3789 {
3790 if ( def == -2 ) hp -= hp;
3791 else hp -= power;
3792 return def;
3793 }
3794 break;
3795 }
3796 break;
3797 }
3798
3799 case wPhantom:
3800 270 return 0;
3801
3802 case wLitBomb:
3803 case wLitSBomb:
3804 case wBait:
3805 case wWind:
3806 case wSSparkle:
3807 103171 return 0;
3808
3809 case wFSparkle:
3810
3811 // Only take sparkle damage if the sparkle's parent item is not
3812 // defended against.
3813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27424 times.
27424 if(enemyHitWeapon > -1)
3814 {
3815 27424 int32_t p = 0;
3816 27424 int32_t f = itemsbuf[enemyHitWeapon].family;
3817
3818
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27424 times.
27424 switch(f)
3819 {
3820 case itype_arrow:
3821 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3822
3823 break;
3824
3825 case itype_cbyrna:
3826 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3827
3828 break;
3829
3830 case itype_brang:
3831
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26955 times.
27424 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3832
3833 469 break;
3834
3835 default:
3836 return 0;
3837 }
3838 469 }
3839
3840 469 wpnId = wSword;
3841 469 power = game->get_hero_dmgmult()>>1;
3842 469 goto fsparkle;
3843 break;
3844
3845 case wBrang:
3846 {
3847 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3848 25029 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3849 //preventing stunlock might be best, here. -Z
3850
2/2
✓ Branch 0 taken 5467 times.
✓ Branch 1 taken 19562 times.
25029 if(def >= 0) return def;
3851
3852 // Not hurt by 0-damage weapons
3853
2/2
✓ Branch 0 taken 3188 times.
✓ Branch 1 taken 16374 times.
19562 if(!(flags & guy_bhit))
3854 {
3855 16374 stunclk=160;
3856
3857
3/4
✓ Branch 0 taken 16374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1305 times.
✓ Branch 3 taken 15069 times.
16374 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3858 {
3859
1/2
✓ Branch 0 taken 1305 times.
✗ Branch 1 not taken.
1305 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3860 1305 goto hitclock;
3861 }
3862
3863 15069 break;
3864 }
3865
3866
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 2793 times.
3188 if(!power)
3867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2793 times.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3868 else
3869 395 hp-=power;
3870
3871 3188 goto hitclock;
3872 }
3873
3874 case wHookshot:
3875 {
3876 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3877 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3878
3879
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3880
3881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3882
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3883 {
3884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3885 1625 stunclk=160;
3886
3887
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3888 {
3889
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3890 549 goto hitclock;
3891 }
3892
3893 1076 break;
3894 }
3895
3896
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3897 else
3898 45 hp-=power;
3899
3900 148 goto hitclock;
3901 }
3902 break;
3903
3904 case wHSHandle:
3905 {
3906
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
3907 523 return 0;
3908
3909
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3911
3912 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3913
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3914
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
3915 2177 return 0;
3916
3917 12102 power = game->get_hero_dmgmult();
3918 12571 }
3919
3920 fsparkle:
3921
3922 [[fallthrough]];
3923 default:
3924 // Work out the defenses!
3925 {
3926 98426 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3927
3928
2/2
✓ Branch 0 taken 26453 times.
✓ Branch 1 taken 71973 times.
98426 if(def >= 0)
3929 26453 return def;
3930
2/2
✓ Branch 0 taken 71513 times.
✓ Branch 1 taken 460 times.
71973 else if(def == -2)
3931 {
3932 460 ret = 0;
3933 460 }
3934 }
3935
3936
2/2
✓ Branch 0 taken 71971 times.
✓ Branch 1 taken 2 times.
143946 if(!power)
3937 {
3938
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3939 2 hp-=1;
3940 else
3941 {
3942 // Don't make a long chain of 'stun' hits
3943 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3944 return 1;
3945
3946
3947 if(!switch_hooked)
3948 stunclk=160;
3949 break;
3950 }
3951 2 }
3952 71971 else hp-=power;
3953
3954 hitclock:
3955 77174 hclk=33;
3956
3957 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3958
2/2
✓ Branch 0 taken 34508 times.
✓ Branch 1 taken 42666 times.
77174 if((dir&2)==(w->dir&2))
3959 {
3960 42666 sclk=(w->dir<<8)+16;
3961 42666 }
3962 77174 }
3963
3964
5/6
✓ Branch 0 taken 73757 times.
✓ Branch 1 taken 19562 times.
✓ Branch 2 taken 21974 times.
✓ Branch 3 taken 71345 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21974 times.
93319 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3965 {
3966 21974 fading=fade_blue_poof;
3967 21974 }
3968
3969
6/6
✓ Branch 0 taken 88397 times.
✓ Branch 1 taken 4922 times.
✓ Branch 2 taken 46724 times.
✓ Branch 3 taken 41673 times.
✓ Branch 4 taken 2134 times.
✓ Branch 5 taken 44590 times.
93319 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3970 {
3971
2/2
✓ Branch 0 taken 7049 times.
✓ Branch 1 taken 7 times.
7056 if( hitsfx > 0 ) //user-set hit sound.
3972 {
3973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7049 times.
7049 if (!dying) //don't play the hit sound on death! -Z
3974 7049 sfx(hitsfx, pan(int32_t(x)));
3975 7049 }
3976 7 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3977 7056 }
3978 else //2.50.2 or earlier
3979 {
3980 86263 sfx(WAV_EHIT, pan(int32_t(x)));
3981 86263 sfx(hitsfx, pan(int32_t(x)));
3982 }
3983
2/2
✓ Branch 0 taken 93290 times.
✓ Branch 1 taken 29 times.
93319 if(family==eeGUY)
3984 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3985
3986 // Penetrating weapons
3987
4/4
✓ Branch 0 taken 91458 times.
✓ Branch 1 taken 1861 times.
✓ Branch 2 taken 84559 times.
✓ Branch 3 taken 8760 times.
93319 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3988 {
3989 8760 int32_t item=enemyHitWeapon;
3990
3991
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 7161 times.
8760 if(wpnId==wArrow)
3992 {
3993 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3994
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1599 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
3995 379 return 0;
3996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
1220 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3997 //if(item<0)
3998 else
3999 1220 item=current_item_id(itype_arrow);
4000 1220 }
4001
4002 else
4003 {
4004
4005 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
4006
3/6
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7143 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7161 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
4007 return 0;
4008
4009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7161 times.
7161 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
4010 else
4011 //if(item<0)
4012 7161 item=current_item_id(itype_sword);
4013 }
4014 8381 }
4015
4016 92940 return ret;
4017 268788 }
4018
4019 61539163 bool enemy::dont_draw()
4020 {
4021
6/6
✓ Branch 0 taken 61076377 times.
✓ Branch 1 taken 462786 times.
✓ Branch 2 taken 61005470 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 172059 times.
✓ Branch 5 taken 60904318 times.
61539163 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4022 634845 return true;
4023
4024
2/2
✓ Branch 0 taken 1371477 times.
✓ Branch 1 taken 59532841 times.
60904318 if(flags&guy_invisible)
4025 1371477 return true;
4026
4027
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59532409 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59532841 if(flags&lens_only && !lensclk)
4028 return true;
4029
4030 59532841 return false;
4031 61539163 }
4032
4033 #define DRAW_NORMAL 2
4034 #define DRAW_CLOAKED 1
4035 #define DRAW_INVIS 0
4036 // base drawing function to be used by all derived classes instead of
4037 // sprite::draw()
4038 44695930 void enemy::draw(BITMAP *dest)
4039 {
4040 44695930 didScriptThisFrame = false; //Since there's no better place to put it
4041
6/6
✓ Branch 0 taken 43932525 times.
✓ Branch 1 taken 763405 times.
✓ Branch 2 taken 43849875 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 314582 times.
✓ Branch 5 taken 43617943 times.
44695930 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4042 1077987 return;
4043
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 40850278 times.
43617943 if(flags&guy_invisible)
4044 2767665 return;
4045
4046 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4047 // be cloaked if they have "invisible displays as cloaked" checked.
4048
4049 40850278 byte canSee = DRAW_NORMAL;
4050 //Enemy specific stuff
4051
2/2
✓ Branch 0 taken 40849114 times.
✓ Branch 1 taken 1164 times.
40850278 if ( editorflags & ENEMY_FLAG1 )
4052 {
4053 1164 canSee = DRAW_INVIS;
4054
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4055
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4056 {
4057 if (game->item[dmisc13])
4058 {
4059 canSee = DRAW_NORMAL;
4060 }
4061 //else if ( lensclk && getlensid.flags SHOWINVIS )
4062 //{
4063 //
4064 //}
4065 //else
4066 //{
4067 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4068 // //otherwisem invisible
4069 //}
4070 }
4071 1164 }
4072 //Room specific
4073
2/2
✓ Branch 0 taken 38679079 times.
✓ Branch 1 taken 2171199 times.
40850278 if (tmpscr->flags3&fINVISROOM)
4074 {
4075
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4077 2171199 }
4078 //Lens check
4079
2/2
✓ Branch 0 taken 27345 times.
✓ Branch 1 taken 40822933 times.
40850278 if (lensclk)
4080 {
4081
2/2
✓ Branch 0 taken 26913 times.
✓ Branch 1 taken 432 times.
27345 if(flags&lens_only)
4082 {
4083
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4084 432 }
4085 27345 }
4086 else
4087 {
4088
2/2
✓ Branch 0 taken 40749517 times.
✓ Branch 1 taken 73416 times.
40822933 if(flags&lens_only)
4089 73416 canSee = DRAW_INVIS;
4090 }
4091
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40775698 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40850278 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4092
3/4
✓ Branch 0 taken 40549694 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40549694 times.
✗ Branch 3 not taken.
40850278 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4093
4094
2/2
✓ Branch 0 taken 40775698 times.
✓ Branch 1 taken 74580 times.
40850278 if (canSee == DRAW_INVIS)
4095 74580 return;
4096
4097
4/4
✓ Branch 0 taken 40773392 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40773385 times.
40775698 if(fallclk||drownclk)
4098 {
4099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 if (canSee == DRAW_CLOAKED)
4100 {
4101 sprite::drawcloaked(dest);
4102 }
4103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 else if (canSee == DRAW_NORMAL)
4104 {
4105 2313 sprite::draw(dest);
4106 2313 }
4107 2313 return;
4108 }
4109 40773385 int32_t cshold=cs;
4110
4111
2/2
✓ Branch 0 taken 901417 times.
✓ Branch 1 taken 39871968 times.
40773385 if(dying)
4112 {
4113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901417 times.
901417 if(clk2>=19)
4114 {
4115 if(!(clk2&2))
4116 {
4117 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4118 if (canSee == DRAW_CLOAKED)
4119 {
4120 sprite::drawcloaked(dest);
4121 }
4122 else if (canSee == DRAW_NORMAL)
4123 {
4124 sprite::draw(dest);
4125 }
4126 }
4127 return;
4128 }
4129
4130 901417 flip = 0;
4131 901417 tile = wpnsbuf[spr_death].tile;
4132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901417 times.
901417 if ( do_animation )
4133 {
4134 901417 int32_t offs = 0;
4135
2/2
✓ Branch 0 taken 850550 times.
✓ Branch 1 taken 50867 times.
901417 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4136 {
4137
2/2
✓ Branch 0 taken 49251 times.
✓ Branch 1 taken 1616 times.
50867 if(clk2 > 2)
4138 {
4139 1616 spr_death_anim_clk=0;
4140 1616 clk2=1;
4141
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1602 times.
1616 if(hp > -1000)
4142 1602 death_sfx();
4143 1616 }
4144
4/4
✓ Branch 0 taken 38168 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 37766 times.
50867 if(clk2==1 && spr_death_anim_clk>-1)
4145 {
4146 37766 ++clk2;
4147
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
37766 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4148
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37745 times.
37766 spr_death_anim_frm *= zc_max(1,txsz);
4149 37766 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4150
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37690 times.
37766 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4151
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 37764 times.
✓ Branch 4 taken 36168 times.
✓ Branch 5 taken 1598 times.
37766 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4152 {
4153 1598 spr_death_anim_clk=-1;
4154 1598 clk2=1;
4155 1598 }
4156 37766 }
4157 50867 tile += spr_death_anim_frm;
4158 50867 }
4159
2/2
✓ Branch 0 taken 313513 times.
✓ Branch 1 taken 537037 times.
850550 else if(BSZ)
4160 {
4161
2/2
✓ Branch 0 taken 246522 times.
✓ Branch 1 taken 66991 times.
313513 offs = zc_min((15-clk2)/3,4);
4162 313513 }
4163
4/4
✓ Branch 0 taken 358103 times.
✓ Branch 1 taken 178934 times.
✓ Branch 2 taken 178923 times.
✓ Branch 3 taken 179180 times.
537037 else if(clk2>6 && clk2<=12)
4164 {
4165 179180 offs = 1;
4166 179180 }
4167
4168
2/2
✓ Branch 0 taken 454874 times.
✓ Branch 1 taken 446543 times.
901417 if(offs)
4169 {
4170
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 446099 times.
446543 offs *= zc_max(1,txsz);
4171 446543 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4172
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 446111 times.
446543 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4173 446543 }
4174 901417 tile += offs;
4175 901417 }
4176
4177
6/6
✓ Branch 0 taken 850550 times.
✓ Branch 1 taken 50867 times.
✓ Branch 2 taken 537037 times.
✓ Branch 3 taken 313513 times.
✓ Branch 4 taken 189344 times.
✓ Branch 5 taken 347693 times.
901417 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4178 553724 cs = wpnsbuf[spr_death].csets&15;
4179 else
4180 347693 cs = (((clk2+5)>>1)&3)+6;
4181 901417 }
4182
3/4
✓ Branch 0 taken 1188432 times.
✓ Branch 1 taken 38683536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1188432 times.
39871968 else if(hclk>0 && getCanFlicker())
4183 {
4184 1188432 cs = getFlashingCSet();
4185 1188432 }
4186 //draw every other frame for flickering enemies
4187
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40525354 times.
40773385 if (is_hitflickerframe(false))
4188 {
4189
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4190
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4191 {
4192 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4193 sprite_flicker_color = temp_flicker_color;
4194 sprite::draw(dest);
4195 }
4196 248031 }
4197 else
4198 {
4199
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40300192 times.
40525354 if (canSee == DRAW_CLOAKED)
4200 {
4201 225162 sprite::drawcloaked(dest);
4202 225162 }
4203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40300192 times.
40300192 else if (canSee == DRAW_NORMAL)
4204 {
4205
1/2
✓ Branch 0 taken 40300192 times.
✗ Branch 1 not taken.
40300192 if ( frozenclock < 0 )
4206 {
4207 if ( frozentile > 0 ) tile = frozentile;
4208 loadpalset(csBOSS,frozencset);
4209 }
4210 40300192 sprite::draw(dest);
4211 40300192 }
4212 }
4213 40773385 cs=cshold;
4214 44695930 }
4215
4216 //old zc bosses
4217 40744744 void enemy::drawzcboss(BITMAP *dest)
4218 {
4219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40744744 times.
40744744 if(dont_draw())
4220 return;
4221
4222 40744744 int32_t cshold=cs;
4223
4224
2/2
✓ Branch 0 taken 781476 times.
✓ Branch 1 taken 39963268 times.
40744744 if(dying)
4225 {
4226
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 777516 times.
781476 if(clk2>=19)
4227 {
4228
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4229 1980 sprite::drawzcboss(dest);
4230
4231 3960 return;
4232 }
4233
4234 777516 flip = 0;
4235 777516 tile = wpnsbuf[spr_death].tile;
4236
4237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777516 times.
777516 if ( do_animation )
4238 {
4239
2/2
✓ Branch 0 taken 773000 times.
✓ Branch 1 taken 4516 times.
777516 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4240 {
4241
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4242 {
4243 6 spr_death_anim_clk=0;
4244 6 clk2=1;
4245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4246 6 death_sfx();
4247 6 }
4248
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4249 {
4250 76 ++clk2;
4251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4253 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4255
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4256 {
4257 2 spr_death_anim_clk=-1;
4258 2 clk2=1;
4259 2 }
4260 76 }
4261 4516 tile += spr_death_anim_frm;
4262 4516 }
4263
2/2
✓ Branch 0 taken 276492 times.
✓ Branch 1 taken 496508 times.
773000 else if(BSZ)
4264
2/2
✓ Branch 0 taken 217484 times.
✓ Branch 1 taken 59008 times.
276492 tile += zc_min((15-clk2)/3,4);
4265
4/4
✓ Branch 0 taken 330969 times.
✓ Branch 1 taken 165539 times.
✓ Branch 2 taken 165382 times.
✓ Branch 3 taken 165587 times.
496508 else if(clk2>6 && clk2<=12)
4266 165587 ++tile;
4267 777516 }
4268
4269
6/6
✓ Branch 0 taken 773000 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496508 times.
✓ Branch 3 taken 276492 times.
✓ Branch 4 taken 184034 times.
✓ Branch 5 taken 312474 times.
777516 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4270 465042 cs = wpnsbuf[spr_death].csets&15;
4271 else
4272 312474 cs = (((clk2+5)>>1)&3)+6;
4273 777516 }
4274
2/2
✓ Branch 0 taken 38764210 times.
✓ Branch 1 taken 1199058 times.
39963268 else if(hclk>0)
4275 {
4276 1199058 cs = getFlashingCSet();
4277 1199058 }
4278
4279
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38695165 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40748327 if((tmpscr->flags3&fINVISROOM) &&
4280
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4282 7543 lensclk) && family!=eeGANON)
4283 {
4284 7543 sprite::drawcloaked(dest);
4285 7543 }
4286 else
4287 {
4288
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40709768 times.
40733241 if (is_hitflickerframe(true))
4289 {
4290
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4291
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4292 {
4293 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4294 sprite_flicker_color = temp_flicker_color;
4295 sprite::drawzcboss(dest);
4296 }
4297 23473 }
4298 else
4299 40709768 sprite::drawzcboss(dest);
4300 }
4301
4302 40740784 cs=cshold;
4303 40744744 }
4304
4305
4306 // similar to the overblock function--can do up to a 32x32 sprite
4307 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4308 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4309 {
4310 323235 int32_t thold=tile;
4311 323235 int32_t t1=tile;
4312 323235 int32_t t2=tile+20;
4313 323235 int32_t t3=tile+1;
4314 323235 int32_t t4=tile+21;
4315
4316
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4317 {
4318 case 1:
4319 enemy::drawzcboss(dest);
4320 break;
4321
4322 case 3:
4323 if(flip&2)
4324 zc_swap(t1,t2);
4325
4326 tile=t1;
4327 enemy::drawzcboss(dest);
4328 tile=t2;
4329 yofs+=16;
4330 enemy::drawzcboss(dest);
4331 yofs-=16;
4332 break;
4333
4334 case 5:
4335 t2=tile+1;
4336
4337 if(flip&1)
4338 zc_swap(t1,t2);
4339
4340 tile=t1;
4341 enemy::drawzcboss(dest);
4342 tile=t2;
4343 xofs+=16;
4344 enemy::drawzcboss(dest);
4345 xofs-=16;
4346 break;
4347
4348 case 15:
4349
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4350 {
4351 6756 zc_swap(t1,t3);
4352 6756 zc_swap(t2,t4);
4353 6756 }
4354
4355
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4356 {
4357 zc_swap(t1,t2);
4358 zc_swap(t3,t4);
4359 }
4360
4361 323235 tile=t1;
4362 323235 enemy::drawzcboss(dest);
4363 323235 tile=t2;
4364 323235 yofs+=16;
4365 323235 enemy::drawzcboss(dest);
4366 323235 yofs-=16;
4367 323235 tile=t3;
4368 323235 xofs+=16;
4369 323235 enemy::drawzcboss(dest);
4370 323235 tile=t4;
4371 323235 yofs+=16;
4372 323235 enemy::drawzcboss(dest);
4373 323235 xofs-=16;
4374 323235 yofs-=16;
4375 323235 break;
4376 }
4377
4378 323235 tile=thold;
4379 323235 }
4380
4381 20230594 void enemy::drawshadow(BITMAP *dest, bool translucent)
4382 {
4383
4/4
✓ Branch 0 taken 18224272 times.
✓ Branch 1 taken 2006322 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 17818183 times.
20230594 if(dont_draw() || isSideViewGravity())
4384 {
4385 2412411 return;
4386 }
4387
4388
2/2
✓ Branch 0 taken 326596 times.
✓ Branch 1 taken 17491587 times.
17818183 if(dying)
4389 {
4390 326596 return;
4391 }
4392
4393
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15773338 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17144577 times.
17491587 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4394 17491587 (darkroom))
4395 {
4396 347010 return;
4397 }
4398 else
4399 {
4400
4/4
✓ Branch 0 taken 16570671 times.
✓ Branch 1 taken 573906 times.
✓ Branch 2 taken 16523304 times.
✓ Branch 3 taken 47367 times.
17144577 if(enemycanfall(id, false) && shadowtile == 0)
4401 47367 shadowtile = wpnsbuf[spr_shadow].tile;
4402
4403
5/6
✓ Branch 0 taken 16206213 times.
✓ Branch 1 taken 938364 times.
✓ Branch 2 taken 16206213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15632307 times.
✓ Branch 5 taken 573906 times.
17144577 if(z>0 || fakez>0 || !enemycanfall(id, false))
4404 {
4405
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1511995 times.
1512270 if(!shadow_overpit(this))
4406 1511995 sprite::drawshadow(dest,translucent);
4407 1512270 }
4408 }
4409 20230594 }
4410
4411 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4412 {
4413 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4414
4415
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4416 {
4417 129181 xofs-=mx;
4418 129181 yofs-=my;
4419 129181 enemy::draw(sub);
4420 129181 xofs+=mx;
4421 129181 yofs+=my;
4422 129181 destroy_bitmap(sub);
4423 129181 }
4424 else
4425 enemy::draw(dest);
4426 129181 }
4427
4428 // override hit detection to check for invicibility, stunned, etc
4429 112136003 bool enemy::hit()
4430 {
4431
4/4
✓ Branch 0 taken 110813163 times.
✓ Branch 1 taken 1322840 times.
✓ Branch 2 taken 109019733 times.
✓ Branch 3 taken 1793430 times.
112136003 if(dying || hclk>0) return false;
4432 109019733 return sprite::hit();
4433 112136003 }
4434 730351 bool enemy::hit(sprite *s)
4435 {
4436
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4437 713374 return sprite::hit(s);
4438 730351 }
4439
4440 44493995 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4441 {
4442
2/2
✓ Branch 0 taken 3916568 times.
✓ Branch 1 taken 40577427 times.
44493995 if(!hit()) return false;
4443 40577427 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4444 44493995 }
4445 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4446 {
4447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4448 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4449 78011 }
4450
4451 11130458 bool enemy::hit(weapon *w)
4452 {
4453
2/2
✓ Branch 0 taken 1170171 times.
✓ Branch 1 taken 9960287 times.
11130458 if(!hit()) return false;
4454
4455
2/2
✓ Branch 0 taken 6645972 times.
✓ Branch 1 taken 3314315 times.
9960287 if (replay_version_check(0, 14))
4456 {
4457
4/6
✓ Branch 0 taken 6421665 times.
✓ Branch 1 taken 224307 times.
✓ Branch 2 taken 6421665 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6421665 times.
✗ Branch 5 not taken.
6645972 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4458 224307 return false;
4459 6421665 return sprite::hit(w);
4460 }
4461 3314315 return w->hit(this);
4462 11130458 }
4463
4464 9448543 bool enemy::can_pitfall(bool checkspawning)
4465 {
4466
4/4
✓ Branch 0 taken 9428722 times.
✓ Branch 1 taken 19821 times.
✓ Branch 2 taken 9418067 times.
✓ Branch 3 taken 30476 times.
9448543 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4467
2/2
✓ Branch 0 taken 9400407 times.
✓ Branch 1 taken 17660 times.
9418067 switch(guysbuf[id&0xFFF].family)
4468 {
4469 case eeAQUA:
4470 case eeDIG:
4471 case eeDONGO:
4472 case eeFAIRY:
4473 case eeGANON:
4474 case eeGHOMA:
4475 case eeGLEEOK:
4476 case eeGUY:
4477 case eeLANM:
4478 case eeMANHAN:
4479 case eeMOLD:
4480 case eeNONE:
4481 case eePATRA:
4482 case eeZORA:
4483 17660 return false; //Disallowed types
4484 default:
4485 9400407 return true;
4486 }
4487 9448543 }
4488 //Handle death
4489 37816380 void enemy::try_death(bool force_kill)
4490 {
4491
8/8
✓ Branch 0 taken 37761623 times.
✓ Branch 1 taken 54757 times.
✓ Branch 2 taken 37761612 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43483 times.
✓ Branch 5 taken 37718129 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43482 times.
37816380 if(!dying && (force_kill || (hp<=0 && !immortal)))
4492 {
4493 43493 std::vector<int32_t> &ev = FFCore.eventData;
4494 43493 ev.clear();
4495 43493 ev.push_back(10000);
4496 43493 ev.push_back(getUID());
4497
4498 43493 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4499 43493 bool isSaved = !ev[0];
4500 43493 ev.clear();
4501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43493 times.
43493 if(isSaved) return;
4502
4503
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 43445 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 42 times.
43493 if(itemguy && (hasitem&2)!=0)
4504 {
4505
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 42 times.
89 for(int32_t i=0; i<items.Count(); i++)
4506 {
4507
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 42 times.
47 if(((item*)items.spr(i))->pickup&ipENEMY)
4508 {
4509
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1 times.
42 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4510 {
4511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4512 {
4513 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4514 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4515 }
4516 else
4517 {
4518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(extend >= 3)
4519 {
4520 items.spr(i)->x = x+(txsz-1)*8;
4521 items.spr(i)->y = y-2+(tysz-1)*8;
4522 }
4523 else
4524 {
4525 1 items.spr(i)->x = x;
4526 1 items.spr(i)->y = y - 2;
4527 }
4528 }
4529 1 items.spr(i)->z = z;
4530 1 items.spr(i)->fakez = fakez;
4531 1 }
4532 else
4533 {
4534 41 items.spr(i)->x = x;
4535 41 items.spr(i)->y = y - 2;
4536 }
4537 42 }
4538 47 }
4539 42 }
4540
4541 43493 dying=true;
4542
4543
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43461 times.
43493 if(fading==fade_flash_die)
4544 32 clk2=19+18*4;
4545 else
4546 {
4547 43461 clk2 = BSZ ? 15 : 19;
4548
4549
2/2
✓ Branch 0 taken 21056 times.
✓ Branch 1 taken 22405 times.
43461 if(fading!=fade_blue_poof)
4550 22405 fading=0;
4551 }
4552
4553
2/2
✓ Branch 0 taken 43445 times.
✓ Branch 1 taken 48 times.
43493 if(itemguy)
4554 {
4555 48 hasitem&=~2;
4556 48 item_set=0;
4557 48 }
4558
4559
6/6
✓ Branch 0 taken 42439 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33754 times.
✓ Branch 3 taken 8685 times.
✓ Branch 4 taken 1402 times.
✓ Branch 5 taken 32352 times.
43493 if(currscr<128 && count_enemy && !script_spawned)
4560 32352 game->guys[(currmap<<7)+currscr]-=1;
4561 43493 }
4562 37816380 }
4563
4564 // --==**==--
4565
4566 // Movement routines that can be used by derived classes as needed
4567
4568 // --==**==--
4569
4570 555845 void enemy::fix_coords(bool bound)
4571 {
4572
1/2
✓ Branch 0 taken 555845 times.
✗ Branch 1 not taken.
555845 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4573
1/2
✓ Branch 0 taken 555845 times.
✗ Branch 1 not taken.
555845 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
4574
4575
4576
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474165 times.
555845 if(bound)
4577 {
4578
1/2
✓ Branch 0 taken 474165 times.
✗ Branch 1 not taken.
474165 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4579 {
4580
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474165 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4581
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474165 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4582 474165 }
4583 else
4584 {
4585 x=vbound(x, 0_zf,240_zf);
4586 y=vbound(y, 0_zf,160_zf);
4587 }
4588 474165 }
4589
4590
6/10
✓ Branch 0 taken 554831 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 555845 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 555845 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 555845 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 555845 times.
555845 if(!OUTOFBOUNDS)
4591 {
4592 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4593
4594 if(isSideViewGravity())
4595 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4596 else
4597 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4598 */
4599 555845 do_fix(x, 16, true);
4600
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 554831 times.
555845 if(isSideViewGravity())
4601 1014 do_fix(y,8,true);
4602 554831 else do_fix(y,16,true);
4603 555845 }
4604 555845 }
4605 9156 bool enemy::cannotpenetrate()
4606 {
4607
4/4
✓ Branch 0 taken 8975 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8937 times.
9156 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4608 }
4609
4610 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4611 {
4612 bool ok;
4613 562 int32_t dx = 0, dy = 0;
4614 562 int32_t sv = 8;
4615
4616 //Why is this here??? Why is it needed???
4617 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4618
4619
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4620 {
4621 case 8:
4622 case up:
4623
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4624 return false;
4625
4626 69 dy = dy1-s;
4627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4629 69 break;
4630
4631 case 12:
4632 case down:
4633
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4634 return false;
4635
4636 51 dy = dy2+s;
4637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4638 51 break;
4639
4640 case 14:
4641 case left:
4642 47 dx = dx1-s;
4643 47 sv = ((isSideViewGravity())?7:8);
4644
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4645
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4646 47 break;
4647
4648 case 10:
4649 case right:
4650 85 dx = dx2+s;
4651 85 sv = ((isSideViewGravity())?7:8);
4652
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4653 85 break;
4654
4655 case 9:
4656 case r_up:
4657 94 dx = dx2+s;
4658 94 dy = dy1-s;
4659
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4661 94 break;
4662
4663 case 11:
4664 case r_down:
4665 78 dx = dx2+s;
4666 78 dx = dy2+s;
4667
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4669 78 break;
4670
4671 case 13:
4672 case l_down:
4673 57 dx = dx1-s;
4674 57 dy = dy2+s;
4675
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4677 57 break;
4678
4679 case 15:
4680 case l_up:
4681 81 dx = dx1-s;
4682 81 dy = dy1-s;
4683
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4685 81 break;
4686
4687 default:
4688 db=99;
4689 return true;
4690 }
4691
4692 562 return ok;
4693 562 }
4694
4695
4696
4697
4698 // returns true if next step is ok, false if there is something there
4699 7325285 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4700 {
4701 7325285 bool ok = false; //initialise the var, son't just declare it
4702 7325285 int32_t dx = 0, dy = 0;
4703 7325285 int32_t sv = 8;
4704 7325285 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4705 //Why is this here??? Why is it needed???
4706 7325285 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325285 times.
7325285 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325285 times.
7325285 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4709
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325272 times.
7325285 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4710
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325272 times.
7325285 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4711 7325285 bool offgrid = OFFGRID_ENEMY;
4712
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7317994 times.
7325285 if(!offgrid)
4713 {
4714 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4715
1/2
✓ Branch 0 taken 7317994 times.
✗ Branch 1 not taken.
7317994 if(usehei<16)usehei=16;
4716
1/2
✓ Branch 0 taken 7317994 times.
✗ Branch 1 not taken.
7317994 if(usewid<16)usewid=16;
4717 7317994 }
4718
9/9
✓ Branch 0 taken 1327891 times.
✓ Branch 1 taken 1102926 times.
✓ Branch 2 taken 1222014 times.
✓ Branch 3 taken 1212951 times.
✓ Branch 4 taken 536645 times.
✓ Branch 5 taken 638123 times.
✓ Branch 6 taken 600184 times.
✓ Branch 7 taken 564898 times.
✓ Branch 8 taken 119653 times.
7325285 switch(ndir) //need to check every 8 pixels between two points
4719 {
4720 case 8:
4721 case up:
4722 {
4723
4/4
✓ Branch 0 taken 150637 times.
✓ Branch 1 taken 1177254 times.
✓ Branch 2 taken 150047 times.
✓ Branch 3 taken 590 times.
1327891 if(enemycanfall(id) && isSideViewGravity())
4724 590 return false;
4725
4726 1327301 dy = dy1-s;
4727
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1326821 times.
1327301 special = (special==spw_clipbottomright)?spw_none:special;
4728 1327301 tries = usewid/(offgrid ? 8 : 16);
4729 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4730
2/2
✓ Branch 0 taken 1127193 times.
✓ Branch 1 taken 1327951 times.
2455144 for ( ; tries > 0; --tries )
4731 {
4732
2/2
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 1130463 times.
1327951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4733 1327951 try_x += (offgrid ? 8 : 16);
4734
2/2
✓ Branch 0 taken 1127843 times.
✓ Branch 1 taken 200108 times.
1327951 if (!ok) break;
4735 1127843 }
4736
2/2
✓ Branch 0 taken 1127193 times.
✓ Branch 1 taken 200108 times.
1327301 if(!ok) break;
4737
1/2
✓ Branch 0 taken 1127193 times.
✗ Branch 1 not taken.
1127193 if((usewid%16)>0) //Uneven width
4738 {
4739 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4740 }
4741 1127193 break;
4742 }
4743 case 12:
4744 case down:
4745 {
4746
4/4
✓ Branch 0 taken 180556 times.
✓ Branch 1 taken 922370 times.
✓ Branch 2 taken 179868 times.
✓ Branch 3 taken 688 times.
1102926 if(enemycanfall(id) && isSideViewGravity())
4747 688 return false;
4748
4749 1102238 dy = dy2+s;
4750 1102238 tries = usewid/(offgrid ? 8 : 16);
4751 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4752
2/2
✓ Branch 0 taken 896247 times.
✓ Branch 1 taken 1103022 times.
1999269 for ( ; tries > 0; --tries )
4753 {
4754
3/4
✓ Branch 0 taken 205243 times.
✓ Branch 1 taken 897779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 897779 times.
1103022 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4755 1103022 try_x += (offgrid ? 8 : 16);
4756
2/2
✓ Branch 0 taken 897031 times.
✓ Branch 1 taken 205991 times.
1103022 if (!ok) break;
4757 897031 }
4758
2/2
✓ Branch 0 taken 896247 times.
✓ Branch 1 taken 205991 times.
1102238 if(!ok) break;
4759
1/2
✓ Branch 0 taken 896247 times.
✗ Branch 1 not taken.
896247 if((usewid%16)>0) //Uneven width
4760 {
4761 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4762 }
4763 896247 break;
4764 }
4765 case 14:
4766 case left:
4767 {
4768 1222014 dx = dx1-s;
4769 1222014 sv = ((isSideViewGravity())?7:0);
4770
4/4
✓ Branch 0 taken 1221391 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1219623 times.
1222014 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4771 1222014 tries = usehei/(offgrid ? 8 : 16);
4772 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4773
2/2
✓ Branch 0 taken 1023089 times.
✓ Branch 1 taken 1222931 times.
2246020 for ( ; tries > 0; --tries )
4774 {
4775
2/2
✓ Branch 0 taken 197742 times.
✓ Branch 1 taken 1025189 times.
1222931 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4776 1222931 try_y += (offgrid ? 8 : 16);
4777
2/2
✓ Branch 0 taken 1024006 times.
✓ Branch 1 taken 198925 times.
1222931 if (!ok) break;
4778 1024006 }
4779
2/2
✓ Branch 0 taken 1023089 times.
✓ Branch 1 taken 198925 times.
1222014 if(!ok) break;
4780
1/2
✓ Branch 0 taken 1023089 times.
✗ Branch 1 not taken.
1023089 if((usehei%16)>0) //Uneven height
4781 {
4782 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4783 }
4784 1023089 break;
4785 }
4786 case 10:
4787 case right:
4788 {
4789 1212951 dx = dx2+s;
4790 1212951 sv = ((isSideViewGravity())?7:0);
4791 1212951 tries = usehei/(offgrid ? 8 : 16);
4792 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4793
2/2
✓ Branch 0 taken 1024852 times.
✓ Branch 1 taken 1213845 times.
2238697 for ( ; tries > 0; --tries )
4794 {
4795
3/4
✓ Branch 0 taken 186746 times.
✓ Branch 1 taken 1027099 times.
✓ Branch 2 taken 1027099 times.
✗ Branch 3 not taken.
1213845 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4796 1213845 try_y += (offgrid ? 8 : 16);
4797
2/2
✓ Branch 0 taken 1025746 times.
✓ Branch 1 taken 188099 times.
1213845 if (!ok) break;
4798 1025746 }
4799
2/2
✓ Branch 0 taken 1024852 times.
✓ Branch 1 taken 188099 times.
1212951 if(!ok) break;
4800
1/2
✓ Branch 0 taken 1024852 times.
✗ Branch 1 not taken.
1024852 if((usehei%16)>0) //Uneven height
4801 {
4802 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4803 }
4804 1024852 break;
4805 }
4806 case 9:
4807 case r_up:
4808 {
4809 536645 dx = dx2+s;
4810 536645 dy = dy1-s;
4811 536645 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4812 536645 sv = ((isSideViewGravity())?7:0);
4813
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_x > 0; --tries_x )
4814 {
4815 536645 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4816 536645 try_y = 0;
4817
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_y > 0; --tries_y )
4818 {
4819
4/4
✓ Branch 0 taken 528401 times.
✓ Branch 1 taken 8244 times.
✓ Branch 2 taken 522980 times.
✓ Branch 3 taken 5421 times.
1059625 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4820
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 520588 times.
522980 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4821 536645 try_y += (offgrid ? 8 : 16);
4822
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4823 519643 }
4824
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519643 times.
519643 if((usehei%16)>0) //Uneven height
4826 {
4827 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4828 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4829 }
4830 519643 try_x += (offgrid ? 8 : 16);
4831 519643 }
4832
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if(!ok) break;
4833
1/2
✓ Branch 0 taken 519643 times.
✗ Branch 1 not taken.
519643 if((usewid%16)>0) //Uneven width
4834 {
4835 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4836 try_y = 0;
4837 for ( ; tries_y > 0; --tries_y )
4838 {
4839 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4840 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4841 try_y += (offgrid ? 8 : 16);
4842 if (!ok) break;
4843 }
4844 if (!ok) break;
4845 if((usehei%16)>0) //Uneven height
4846 {
4847 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4848 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4849 }
4850 }
4851 519643 break;
4852 }
4853 case 11:
4854 case r_down:
4855 {
4856 638123 dx = dx2+s;
4857 638123 dx = dy2+s;
4858 638123 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4859 //sv = ((isSideViewGravity())?7:0);
4860
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_x > 0; --tries_x )
4861 {
4862 638123 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4863 638123 try_y = 0;
4864
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_y > 0; --tries_y )
4865 {
4866
4/4
✓ Branch 0 taken 636612 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 623840 times.
✓ Branch 3 taken 12772 times.
1261963 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4867
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 623734 times.
623840 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4868 638123 try_y += (offgrid ? 8 : 16);
4869
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4870 622773 }
4871
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 622773 times.
622773 if((usehei%16)>0) //Uneven height
4873 {
4874 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4875 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4876 }
4877 622773 try_x += (offgrid ? 8 : 16);
4878 622773 }
4879
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if(!ok) break;
4880
1/2
✓ Branch 0 taken 622773 times.
✗ Branch 1 not taken.
622773 if((usewid%16)>0) //Uneven width
4881 {
4882 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4883 try_y = 0;
4884 for ( ; tries_y > 0; --tries_y )
4885 {
4886 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4887 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4888 try_y += (offgrid ? 8 : 16);
4889 if (!ok) break;
4890 }
4891 if (!ok) break;
4892 if((usehei%16)>0) //Uneven height
4893 {
4894 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4895 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4896 }
4897 }
4898 622773 break;
4899 }
4900 case 13:
4901 case l_down:
4902 {
4903 600184 dx = dx1-s;
4904 600184 dy = dy2+s;
4905 600184 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4906 //sv = ((isSideViewGravity())?7:0);
4907
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_x > 0; --tries_x )
4908 {
4909 600184 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4910 600184 try_y = 0;
4911
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_y > 0; --tries_y )
4912 {
4913
4/4
✓ Branch 0 taken 588277 times.
✓ Branch 1 taken 11907 times.
✓ Branch 2 taken 584012 times.
✓ Branch 3 taken 4265 times.
1184196 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4914
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 583444 times.
584012 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4915 600184 try_y += (offgrid ? 8 : 16);
4916
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4917 583146 }
4918
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583146 times.
583146 if((usehei%16)>0) //Uneven height
4920 {
4921 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4922 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4923 }
4924 583146 try_x += (offgrid ? 8 : 16);
4925 583146 }
4926
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if(!ok) break;
4927
1/2
✓ Branch 0 taken 583146 times.
✗ Branch 1 not taken.
583146 if((usewid%16)>0) //Uneven width
4928 {
4929 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4930 try_y = 0;
4931 for ( ; tries_y > 0; --tries_y )
4932 {
4933 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4934 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4935 try_y += (offgrid ? 8 : 16);
4936 if (!ok) break;
4937 }
4938 if (!ok) break;
4939 if((usehei%16)>0) //Uneven height
4940 {
4941 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4942 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4943 }
4944 }
4945 583146 break;
4946 }
4947 case 15:
4948 case l_up:
4949 {
4950 564898 dx = dx1-s;
4951 564898 dy = dy1-s;
4952 564898 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4953 564898 sv = ((isSideViewGravity())?7:0);
4954
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_x > 0; --tries_x )
4955 {
4956 564898 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4957 564898 try_y = 0;
4958
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_y > 0; --tries_y )
4959 {
4960
4/4
✓ Branch 0 taken 556265 times.
✓ Branch 1 taken 8633 times.
✓ Branch 2 taken 552308 times.
✓ Branch 3 taken 3957 times.
1117206 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4961
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 549869 times.
552308 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4962 564898 try_y += (offgrid ? 8 : 16);
4963
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4964 549004 }
4965
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549004 times.
549004 if((usehei%16)>0) //Uneven height
4967 {
4968 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4969 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4970 }
4971 549004 try_x += (offgrid ? 8 : 16);
4972 549004 }
4973
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if(!ok) break;
4974
1/2
✓ Branch 0 taken 549004 times.
✗ Branch 1 not taken.
549004 if((usewid%16)>0) //Uneven width
4975 {
4976 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4977 try_y = 0;
4978 for ( ; tries_y > 0; --tries_y )
4979 {
4980 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4981 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4982 try_y += (offgrid ? 8 : 16);
4983 if (!ok) break;
4984 }
4985 if (!ok) break;
4986 if((usehei%16)>0) //Uneven height
4987 {
4988 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4989 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4990 }
4991 }
4992 549004 break;
4993 }
4994 default:
4995 119653 db=99;
4996 119653 return true;
4997 }
4998 //Z_eventlog("\n");
4999 7204354 return ok;
5000 7325285 }
5001
5002
5003 4624298 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
5004 {
5005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624298 times.
4624298 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624298 times.
4624298 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5007
1/2
✓ Branch 0 taken 4624298 times.
✗ Branch 1 not taken.
4624298 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5008
1/2
✓ Branch 0 taken 4624298 times.
✗ Branch 1 not taken.
4624298 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5009 4624298 --usewid;
5010 4624298 --usehei;
5011 4624298 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5012 }
5013
5014 1243207 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5015 {
5016 1243207 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5017
5018
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1236388 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1243207 if(special==spw_clipright&&ndir==right)
5019 {
5020 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5021 1798 }
5022
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243202 times.
1243207 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5023
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243202 times.
1243207 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5024
1/2
✓ Branch 0 taken 1243207 times.
✗ Branch 1 not taken.
1243207 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5025
1/2
✓ Branch 0 taken 1243207 times.
✗ Branch 1 not taken.
1243207 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5026 1243207 --usewid;
5027 1243207 --usehei;
5028
2/2
✓ Branch 0 taken 716881 times.
✓ Branch 1 taken 526326 times.
1243207 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5029 }
5030
5031 136202 bool enemy::canmove(int32_t ndir, bool kb)
5032 {
5033 136202 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5034 }
5035
5036 // 8-directional
5037 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5038 {
5039 562 int32_t ndir=0;
5040
5041 // can move straight, check if it wants to turn
5042
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5043 {
5044
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5045 {
5046 int32_t w = Lwpns.idFirst(wBait);
5047
5048 if(w>=0)
5049 {
5050 int32_t bx = Lwpns.spr(w)->x;
5051 int32_t by = Lwpns.spr(w)->y;
5052
5053 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5054
5055 if(abs(int32_t(y)-by)>14)
5056 {
5057 if(ndir>0) // Already left or right
5058 {
5059 // Making the diagonal directions
5060 ndir += (by<y) ? 2 : 4;
5061 }
5062 else
5063 {
5064 ndir = (by<y) ? up : down;
5065 }
5066 }
5067
5068 if(canmove(ndir,special,false))
5069 {
5070 dir=ndir;
5071 return;
5072 }
5073 }
5074 }
5075
5076 // Homing added.
5077
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5078 {
5079 ndir = lined_up(8,true);
5080
5081 if(ndir>=0 && canmove(ndir,special,false))
5082 {
5083 dir=ndir;
5084 }
5085
5086 return;
5087 }
5088
5089 549 int32_t r=zc_oldrand();
5090
5091
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5092 {
5093 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5094 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5095
5096
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5097 525 dir=ndir;
5098
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5099 19 dir=ndir2;
5100
5101
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5102 // due to numerous lost fractional components. -L
5103 {
5104 x.doFloor();
5105 y.doFloor();
5106 }
5107 549 }
5108
5109 549 return;
5110 }
5111
5112 // can't move straight, must turn
5113 13 int32_t i=0;
5114
5115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5116 {
5117 20 ndir=(zc_oldrand()&7)+8;
5118
5119
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5120 13 break;
5121 7 }
5122
5123
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5124 {
5125 for(ndir=8; ndir<16; ndir++)
5126 {
5127 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5128 goto ok;
5129 }
5130
5131 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5132 }
5133
5134 ok:
5135 13 dir=ndir;
5136 13 x.doFloor();
5137 13 y.doFloor();
5138 562 }
5139
5140 577113 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5141 {
5142 577113 int32_t ndir=0;
5143
5144 // can move straight, check if it wants to turn
5145
2/2
✓ Branch 0 taken 544558 times.
✓ Branch 1 taken 32555 times.
577113 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5146 {
5147
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 544351 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
544558 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5148 {
5149 101 int32_t i = Lwpns.idFirst(wBait);
5150
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5151 {
5152 weapon *w = (weapon*)Lwpns.spr(i);
5153 if (get_qr(qr_FIND_CLOSEST_BAIT))
5154 {
5155 int32_t currentrange;
5156 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5157 else currentrange = -1;
5158 int curid = i;
5159 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5160 for(; i<Lwpns.Count(); ++i)
5161 {
5162 weapon *lw = (weapon*)Lwpns.spr(i);
5163 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5164 {
5165 currentrange = distance(x, y, lw->x, lw->y);
5166 curid = i;
5167 }
5168 }
5169 i = curid;
5170 if (currentrange == -1) i = -1;
5171 }
5172 else
5173 {
5174 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5175 }
5176 if(i>=0)
5177 {
5178 int32_t bx = Lwpns.spr(i)->x;
5179 int32_t by = Lwpns.spr(i)->y;
5180
5181 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5182
5183 if(abs(int32_t(y)-by)>14)
5184 {
5185 if(ndir>0) // Already left or right
5186 {
5187 // Making the diagonal directions
5188 ndir += (by<y) ? 2 : 4;
5189 }
5190 else
5191 {
5192 ndir = (by<y) ? up : down;
5193 }
5194 }
5195 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5196 if(canmove(ndir,special,false))
5197 {
5198 dir=ndir;
5199 return;
5200 }
5201 }
5202 }
5203 101 }
5204
5205 // Homing added.
5206
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 514932 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
544558 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5207 {
5208 14216 ndir = lined_up(8,true);
5209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5210
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5211 {
5212 5852 dir=ndir;
5213 5852 }
5214
5215 14216 return;
5216 }
5217
5218 530342 int32_t r=zc_oldrand();
5219
5220
4/4
✓ Branch 0 taken 338430 times.
✓ Branch 1 taken 191912 times.
✓ Branch 2 taken 178921 times.
✓ Branch 3 taken 159509 times.
530342 if(newrate>0 && !(r%newrate))
5221 {
5222 159509 ndir = ((dir+((r&64)?-1:1))&7)+8;
5223 159509 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5224
5225
2/2
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
159509 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5226 153722 dir=ndir;
5227
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4930 times.
5787 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5228 4930 dir=ndir2;
5229
5230
4/4
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
✓ Branch 2 taken 146396 times.
✓ Branch 3 taken 7326 times.
159509 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5231 // due to numerous lost fractional components. -L
5232 {
5233 7326 x.doFloor();
5234 7326 y.doFloor();
5235 7326 }
5236 159509 }
5237
5238 530342 return;
5239 }
5240
5241 // can't move straight, must turn
5242 32555 int32_t i=0;
5243
5244
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 60993 times.
61063 for(; i<32; i++) // Try random dir
5245 {
5246 60993 ndir=(zc_oldrand()&7)+8;
5247
5248
2/2
✓ Branch 0 taken 28508 times.
✓ Branch 1 taken 32485 times.
60993 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5249 32485 break;
5250 28508 }
5251
5252
2/2
✓ Branch 0 taken 32485 times.
✓ Branch 1 taken 70 times.
32608 if(i==32)
5253 {
5254
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5255 {
5256
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5257 17 goto ok;
5258 444 }
5259
5260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5261 53 }
5262
5263 ok:
5264 32555 dir=ndir;
5265 32555 x.doFloor();
5266 32555 y.doFloor();
5267 577113 }
5268
5269 570638 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5270 {
5271 570638 newdir_8(newrate,newhoming,special,0,-8,15,15);
5272 570638 }
5273
5274 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5275 {
5276 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5277 562 }
5278
5279 // makes the enemy slide backwards when hit
5280 // sclk: first byte is clk, second byte is dir
5281 // makes the enemy slide backwards when hit
5282 // sclk: first byte is clk, second byte is dir
5283 15625251 int32_t enemy::slide()
5284 {
5285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15625251 times.
15625251 if(script_knockback_clk!=0) //scripted knockback
5286 {
5287 sclk = 0;
5288 return 1; //scripted knockback ran
5289 }
5290
5/6
✓ Branch 0 taken 102102 times.
✓ Branch 1 taken 15523149 times.
✓ Branch 2 taken 7848 times.
✓ Branch 3 taken 94254 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7848 times.
15625251 if(sclk==0 || (hp<=0 && !immortal))
5291 15530997 return 0;
5292
5293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94254 times.
94254 if(knockbackflags & FLAG_NOSLIDE)
5294 {
5295 sclk = 0;
5296 if(!OFFGRID_ENEMY)
5297 {
5298 //Fix to grid
5299 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5300 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5301 do_fix(x, 16, true);
5302 do_fix(y, 16, true);
5303 }
5304 return 0;
5305 }
5306
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84700 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 9258 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 7105 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 296 times.
94254 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5307 {
5308 2153 sclk=0;
5309 2153 return 0;
5310 }
5311
5312 92101 --sclk;
5313
5314
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35752 times.
92101 switch(sclk>>8)
5315 {
5316 case up:
5317 {
5318
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5319 {
5320 7 sclk=0;
5321 7 return 0;
5322 }
5323
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5324
5325 10357 break;
5326 }
5327 case down:
5328 {
5329
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5330 {
5331 2 sclk=0;
5332 2 return 0;
5333 }
5334
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5335
5336 12143 break;
5337 }
5338 case left:
5339 {
5340
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5341 {
5342 13 sclk=0;
5343 13 return 0;
5344 }
5345
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5346
5347 31483 break;
5348 }
5349 case right:
5350 {
5351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35752 times.
35752 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5352 {
5353 sclk=0;
5354 return 0;
5355 }
5356
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32464 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35752 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5357 35482 break;
5358 }
5359 }
5360
5361 91250 int32_t move = knockbackSpeed;
5362
2/2
✓ Branch 0 taken 86366 times.
✓ Branch 1 taken 91250 times.
177616 while(move>0)
5363 {
5364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91250 times.
91250 int32_t thismove = zc_min(8, move);
5365 91250 move -= thismove;
5366 91250 hitdir = (sclk>>8);
5367
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35482 times.
91250 switch(sclk>>8)
5368 {
5369 case up:
5370 10357 y-=thismove;
5371 10357 break;
5372
5373 case down:
5374 12143 y+=thismove;
5375 12143 break;
5376
5377 case left:
5378 31483 x-=thismove;
5379 31483 break;
5380
5381 case right:
5382 35482 x+=thismove;
5383 35482 break;
5384 }
5385
2/2
✓ Branch 0 taken 86366 times.
✓ Branch 1 taken 4884 times.
91250 if(!canmove(sclk>>8,(zfix)0,0,true))
5386 {
5387
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2907 times.
✓ Branch 2 taken 4 times.
4884 switch(sclk>>8)
5388 {
5389 case up:
5390 case down:
5391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5392 y = 0;
5393
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5394 325 y=(int32_t(y)&0xF0)+16;
5395 else
5396 1648 y=(int32_t(y)&0xF0);
5397
5398 1973 break;
5399
5400 case left:
5401 case right:
5402
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2903 times.
2907 if(x < 0)
5403 4 x = 0;
5404
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2070 times.
2903 else if((int32_t(x)&15) > 7)
5405 833 x=(int32_t(x)&0xF0)+16;
5406 else
5407 2070 x=(int32_t(x)&0xF0);
5408
5409 2907 break;
5410 }
5411
5412 4884 sclk=0;
5413 4884 clk3=0;
5414 4884 break;
5415 }
5416 }
5417
5418
2/2
✓ Branch 0 taken 83887 times.
✓ Branch 1 taken 7363 times.
91250 if((sclk&255)==0)
5419 {
5420 //hitdir = -1;
5421 7363 sclk=0;
5422 7363 }
5423 91250 return 2;
5424 15625251 }
5425
5426 bool enemy::can_slide()
5427 {
5428 if(sclk==0 || (hp<=0 && !immortal))
5429 return false;
5430
5431 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5432 {
5433 return false;
5434 }
5435
5436 return true;
5437 }
5438
5439 bool enemy::fslide()
5440 {
5441 if(sclk==0 || (hp<=0 && !immortal))
5442 return false;
5443
5444 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5445 {
5446 sclk=0;
5447 return false;
5448 }
5449
5450 --sclk;
5451
5452 switch(sclk>>8)
5453 {
5454 case up:
5455 if(y<=16)
5456 {
5457 sclk=0;
5458 return false;
5459 }
5460
5461 break;
5462
5463 case down:
5464 if(y>=160)
5465 {
5466 sclk=0;
5467 return false;
5468 }
5469
5470 break;
5471
5472 case left:
5473 if(x<=16)
5474 {
5475 sclk=0;
5476 return false;
5477 }
5478
5479 break;
5480
5481 case right:
5482 if(x>=240)
5483 {
5484 sclk=0;
5485 return false;
5486 }
5487
5488 break;
5489 }
5490 hitdir = (sclk>>8);
5491 switch(sclk>>8)
5492 {
5493 case up:
5494 y-=4;
5495 break;
5496
5497 case down:
5498 y+=4;
5499 break;
5500
5501 case left:
5502 x-=4;
5503 break;
5504
5505 case right:
5506 x+=4;
5507 break;
5508 }
5509
5510 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5511 {
5512 switch(sclk>>8)
5513 {
5514 case up:
5515 case down:
5516 if((int32_t(y)&15) > 7)
5517 y=(int32_t(y)&0xF0)+16;
5518 else
5519 y=(int32_t(y)&0xF0);
5520
5521 break;
5522
5523 case left:
5524 case right:
5525 if((int32_t(x)&15) > 7)
5526 x=(int32_t(x)&0xF0)+16;
5527 else
5528 x=(int32_t(x)&0xF0);
5529
5530 break;
5531 }
5532
5533 sclk=0;
5534 clk3=0;
5535 }
5536
5537 if((sclk&255)==0)
5538 sclk=0;
5539
5540 return true;
5541 }
5542
5543 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5544 {
5545 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5546 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5547 bool ret = sprite::knockback(time, dir, speed);
5548 if(ret) sclk = 0; //kill engine knockback if interrupted
5549 //! Perhaps also set hitdir here, if needed for timing? -Z
5550 return ret;
5551 }
5552
5553 37816369 bool enemy::runKnockback()
5554 {
5555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37816369 times.
37816369 if((script_knockback_clk&0xFF)==0)
5556 {
5557 37816369 script_knockback_clk = 0;
5558 37816369 return false;
5559 }
5560 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5561 {
5562 return false;
5563 }
5564 int32_t move = script_knockback_speed;
5565 int32_t kb_dir = script_knockback_clk>>8;
5566 --script_knockback_clk;
5567
5568 while(move>0)
5569 {
5570 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5571 move -= thismove;
5572 hitdir = kb_dir;
5573 switch(kb_dir)
5574 {
5575 case r_up:
5576 case l_up:
5577 case up:
5578 y-=thismove;
5579 break;
5580
5581 case r_down:
5582 case l_down:
5583 case down:
5584 y+=thismove;
5585 break;
5586 }
5587 switch(kb_dir)
5588 {
5589 case l_up:
5590 case l_down:
5591 case left:
5592 x-=thismove;
5593 break;
5594
5595 case r_up:
5596 case r_down:
5597 case right:
5598 x+=thismove;
5599 break;
5600 }
5601 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5602 {
5603 if(!canmove(kb_dir,(zfix)0,0,true))
5604 {
5605 script_knockback_clk=0;
5606 clk3=0;
5607 //Fix to grid
5608 switch(kb_dir)
5609 {
5610 case up:
5611 case down:
5612 break;
5613 default:
5614 if(x < 0)
5615 x = 0;
5616 else if((int32_t(x)&15) > 7)
5617 x=(int32_t(x)&0xF0)+16;
5618 else
5619 x=(int32_t(x)&0xF0);
5620 break;
5621 }
5622 switch(kb_dir)
5623 {
5624 case left:
5625 case right:
5626 break;
5627 default:
5628 if(y < 0)
5629 y = 0;
5630 else if((int32_t(y)&15) > 7)
5631 y=(int32_t(y)&0xF0)+16;
5632 else
5633 y=(int32_t(y)&0xF0);
5634 break;
5635 }
5636 break;
5637 }
5638 }
5639 else
5640 {
5641 if(!scr_canplace(x,y,0,true))
5642 {
5643 script_knockback_clk=0;
5644 clk3=0;
5645 //Fix to grid
5646 if (OFFGRID_ENEMY)
5647 {
5648 switch(kb_dir)
5649 {
5650 case up:
5651 case down:
5652 break;
5653 default:
5654 if(x < 0)
5655 x = 0;
5656 else if((int32_t(x)&7) > 3)
5657 x=(int32_t(x)&0xF8)+8;
5658 else
5659 x=(int32_t(x)&0xF8);
5660 break;
5661 }
5662 switch(kb_dir)
5663 {
5664 case left:
5665 case right:
5666 break;
5667 default:
5668 if(y < 0)
5669 y = 0;
5670 else if((int32_t(y)&7) > 3)
5671 y=(int32_t(y)&0xF8)+8;
5672 else
5673 y=(int32_t(y)&0xF8);
5674 break;
5675 }
5676 }
5677 else
5678 {
5679 switch(kb_dir)
5680 {
5681 case up:
5682 case down:
5683 break;
5684 default:
5685 if(x < 0)
5686 x = 0;
5687 else if((int32_t(x)&15) > 7)
5688 x=(int32_t(x)&0xF0)+16;
5689 else
5690 x=(int32_t(x)&0xF0);
5691 break;
5692 }
5693 switch(kb_dir)
5694 {
5695 case left:
5696 case right:
5697 break;
5698 default:
5699 if(y < 0)
5700 y = 0;
5701 else if((int32_t(y)&15) > 7)
5702 y=(int32_t(y)&0xF0)+16;
5703 else
5704 y=(int32_t(y)&0xF0);
5705 break;
5706 }
5707 }
5708 break;
5709 }
5710
5711 }
5712 }
5713 return true;
5714 37816369 }
5715 // changes enemy's direction, checking restrictions
5716 // rate: 0 = no random changes, 16 = always random change
5717 // homing: 0 = none, 256 = always
5718 // grumble 0 = none, 4 = strongest appetite
5719 520367 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5720 {
5721 520367 int32_t ndir=-1;
5722
5723
4/4
✓ Branch 0 taken 109954 times.
✓ Branch 1 taken 410413 times.
✓ Branch 2 taken 37802 times.
✓ Branch 3 taken 72152 times.
520367 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5724 {
5725 72152 int32_t i = Lwpns.idFirst(wBait);
5726
1/2
✓ Branch 0 taken 72152 times.
✗ Branch 1 not taken.
72152 if(i >= 0) //idfirst returns -1 if it can't find any
5727 {
5728 weapon *w = (weapon*)Lwpns.spr(i);
5729 if (get_qr(qr_FIND_CLOSEST_BAIT))
5730 {
5731 int32_t currentrange;
5732 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5733 else currentrange = -1;
5734 int curid = i;
5735 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5736 for(; i<Lwpns.Count(); ++i)
5737 {
5738 weapon *lw = (weapon*)Lwpns.spr(i);
5739 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5740 {
5741 currentrange = distance(x, y, lw->x, lw->y);
5742 curid = i;
5743 }
5744 }
5745 i = curid;
5746 if (currentrange == -1) i = -1;
5747 }
5748 else
5749 {
5750 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5751 }
5752 if (i >= 0)
5753 {
5754 int32_t bx = Lwpns.spr(i)->x;
5755 int32_t by = Lwpns.spr(i)->y;
5756
5757 if(abs(int32_t(y)-by)>14)
5758 {
5759 ndir = (by<y) ? up : down;
5760 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5761 if(canmove(ndir,special,false))
5762 {
5763 dir=ndir;
5764 return;
5765 }
5766 }
5767
5768 ndir = (bx<x) ? left : right;
5769 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5770 if(canmove(ndir,special,false))
5771 {
5772 dir=ndir;
5773 return;
5774 }
5775 }
5776 }
5777 72152 }
5778
5779
2/2
✓ Branch 0 taken 352478 times.
✓ Branch 1 taken 167889 times.
520367 if((zc_oldrand()&255)<abs(newhoming))
5780 {
5781 167889 ndir = lined_up(8,false);
5782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167889 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167889 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5783
4/4
✓ Branch 0 taken 45334 times.
✓ Branch 1 taken 122555 times.
✓ Branch 2 taken 5715 times.
✓ Branch 3 taken 39619 times.
167889 if(ndir>=0 && canmove(ndir,special,false))
5784 {
5785 39619 dir=ndir;
5786 39619 return;
5787 }
5788 128270 }
5789
5790 480748 int32_t i=0;
5791
5792
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 1179509 times.
1182844 for(; i<32; i++)
5793 {
5794 1179509 int32_t r=zc_oldrand();
5795
5796
2/2
✓ Branch 0 taken 344692 times.
✓ Branch 1 taken 834817 times.
1179509 if((r&15)<newrate)
5797 344692 ndir=(r>>4)&3;
5798 else
5799 834817 ndir=dir;
5800
5801
2/2
✓ Branch 0 taken 702096 times.
✓ Branch 1 taken 477413 times.
1179509 if(canmove(ndir,special,false))
5802 477413 break;
5803 702096 }
5804
5805
2/2
✓ Branch 0 taken 477413 times.
✓ Branch 1 taken 3335 times.
481501 if(i==32)
5806 {
5807
2/2
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 753 times.
9672 for(ndir=0; ndir<4; ndir++)
5808 {
5809
2/2
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 2582 times.
8919 if(canmove(ndir,special,false))
5810 2582 goto ok;
5811 6337 }
5812
5813
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 693 times.
753 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5814 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5815 753 }
5816
5817 ok:
5818 480748 dir = ndir;
5819 520367 }
5820
5821 2633 void enemy::newdir()
5822 {
5823 2633 newdir(4,0,spw_none);
5824 2633 }
5825
5826 zfix enemy::distance_left()
5827 {
5828 int32_t a2=x.getInt();
5829 int32_t b2=y.getInt();
5830
5831 switch(dir)
5832 {
5833 case up:
5834 return (zfix)(b2&0xF);
5835
5836 case down:
5837 return (zfix)(16-(b2&0xF));
5838
5839 case left:
5840 return (zfix)(a2&0xF);
5841
5842 case right:
5843 return (zfix)(16-(a2&0xF));
5844 }
5845
5846 return (zfix)0;
5847 }
5848
5849 // keeps walking around
5850 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5851 {
5852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5853 return;
5854
5855
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5856 8261 return;
5857
5858
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5859 {
5860 26115 fix_coords(true);
5861 26115 newdir(newrate,newhoming,special);
5862
5863
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5864 clk3=0;
5865 else
5866 26115 clk3=int32_t(16.0/step);
5867 26115 }
5868
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5869 {
5870 45 dir^=1;
5871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5872 else clk3=32767;
5873 45 }
5874
5875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5876 383173 move(step);
5877 391434 }
5878
5879 void enemy::constant_walk()
5880 {
5881 constant_walk(4,0,spw_none);
5882 }
5883
5884 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5885 {
5886 35220 return (newy<<8)+newx;
5887 }
5888
5889 // for variable step rates
5890 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5891 {
5892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5893 return;
5894
5895
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5896 55444 return;
5897
5898 418370 zfix dx = (zfix)0;
5899 418370 zfix dy = (zfix)0;
5900
5901
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5902 {
5903 case 8:
5904 case up:
5905 93441 dy-=step;
5906 93441 break;
5907
5908 case 12:
5909 case down:
5910 97752 dy+=step;
5911 97752 break;
5912
5913 case 14:
5914 case left:
5915 111603 dx-=step;
5916 111603 break;
5917
5918 case 10:
5919 case right:
5920 113743 dx+=step;
5921 113743 break;
5922
5923 case 15:
5924 case l_up:
5925 dx-=step;
5926 dy-=step;
5927 break;
5928
5929 case 9:
5930 case r_up:
5931 dx+=step;
5932 dy-=step;
5933 break;
5934
5935 case 13:
5936 case l_down:
5937 dx-=step;
5938 dy+=step;
5939 break;
5940
5941 case 11:
5942 case r_down:
5943 dx+=step;
5944 dy+=step;
5945 break;
5946 }
5947
5948
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5949 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5950 {
5951 12443 fix_coords();
5952 12443 newdir(newrate,newhoming,special);
5953 12443 clk3=pos(x,y);
5954 12443 }
5955
5956 418370 move(step);
5957 473814 }
5958
5959 // pauses for a while after it makes a complete move (to a new square)
5960 12316472 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5961 {
5962
4/4
✓ Branch 0 taken 79889 times.
✓ Branch 1 taken 12236583 times.
✓ Branch 2 taken 67057 times.
✓ Branch 3 taken 12832 times.
12316472 if(sclk && clk2)
5963 {
5964 12832 clk3=0;
5965 12832 }
5966
5967
11/14
✓ Branch 0 taken 12243450 times.
✓ Branch 1 taken 73022 times.
✓ Branch 2 taken 12243450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12243450 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11776236 times.
✓ Branch 7 taken 467214 times.
✓ Branch 8 taken 11638487 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11635279 times.
✓ Branch 11 taken 3208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11635279 times.
12316472 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5968 {
5969 681193 return;
5970 }
5971
5972
2/2
✓ Branch 0 taken 2132459 times.
✓ Branch 1 taken 9502820 times.
11635279 if(clk2>0)
5973 {
5974 2132459 --clk2;
5975 2132459 return;
5976 }
5977
5978
2/2
✓ Branch 0 taken 410660 times.
✓ Branch 1 taken 9092160 times.
9502820 if(clk3<=0)
5979 {
5980 410660 fix_coords(true);
5981 410660 newdir(newrate,newhoming,special);
5982 410660 clk3=int32_t(16.0/step);
5983
2/2
✓ Branch 0 taken 410465 times.
✓ Branch 1 taken 195 times.
410660 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410660 times.
410660 if(clk2<0)
5985 {
5986 clk2=0;
5987 }
5988
2/2
✓ Branch 0 taken 54758 times.
✓ Branch 1 taken 355902 times.
410660 else if((zc_oldrand()&15)<newhrate)
5989 {
5990 54758 clk2=haltcnt;
5991 54758 return;
5992 }
5993 355902 }
5994
2/2
✓ Branch 0 taken 9089001 times.
✓ Branch 1 taken 3159 times.
9092160 else if(scored)
5995 {
5996 3159 dir^=1;
5997
5998
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5999 5 else clk3=32767;
6000 3159 }
6001
6002
2/2
✓ Branch 0 taken 74649 times.
✓ Branch 1 taken 9373413 times.
9448062 if (step != 0) --clk3;
6003 9448062 move(step);
6004 12316472 }
6005
6006 // 8-directional movement, aligns to 8 pixels
6007 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
6008 {
6009 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6010 return;
6011
6012 if(clk3<=0)
6013 {
6014 newdir_8(newrate,newhoming,special);
6015 clk3=int32_t(8.0/step);
6016 if (step == 0) clk3 = 32767;
6017 }
6018
6019 if (step != 0) --clk3;
6020 move(step);
6021 }
6022 // 8-directional movement, aligns to 8 pixels
6023 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6024 {
6025
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6026 return;
6027
6028
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6029 {
6030 16235 newdir_8(newrate,newhoming,special);
6031 16235 clk3=int32_t(8.0/step);
6032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6033 16235 }
6034
6035
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6036 242393 move(step);
6037 242393 }
6038
6039 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6040 {
6041 if(clk<0 || dying || stunclk || watch || frozenclock)
6042 return;
6043
6044 if(!canmove(dir,step,special,false))
6045 clk3=0;
6046
6047 if(clk2>0)
6048 {
6049 --clk2;
6050 return;
6051 }
6052
6053 if(clk3<=0)
6054 {
6055 newdir_8(newrate,newhoming,special);
6056 clk3=newclk;
6057
6058 if(clk2<0)
6059 {
6060 clk2=0;
6061 }
6062 else if((zc_oldrand()&15)<newhrate)
6063 {
6064 newdir_8(newrate,newhoming,special);
6065 clk2=haltcnt;
6066 return;
6067 }
6068 }
6069
6070 --clk3;
6071 move(step);
6072 }
6073
6074 // 8-directional movement, no alignment
6075 4691075 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6076 {
6077
9/12
✓ Branch 0 taken 4483752 times.
✓ Branch 1 taken 207323 times.
✓ Branch 2 taken 4483752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4457131 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4446084 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4446084 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4446084 times.
4691075 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6078 244991 return;
6079
6080
2/2
✓ Branch 0 taken 4415704 times.
✓ Branch 1 taken 30380 times.
4446084 if(!canmove(dir,step,special,false))
6081 30380 clk3=0;
6082
6083
2/2
✓ Branch 0 taken 3891681 times.
✓ Branch 1 taken 554403 times.
4446084 if(clk3<=0)
6084 {
6085 554403 newdir_8(newrate,newhoming,special);
6086 554403 clk3=newclk;
6087 554403 }
6088
6089 4446084 --clk3;
6090 4446084 move(step);
6091 4691075 }
6092
6093 // same as above but with variable enemy size
6094 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6095 {
6096
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6097 1247 return;
6098
6099
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6100 1334 clk3=0;
6101
6102
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6103 {
6104 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6105 6475 clk3=newclk;
6106 6475 }
6107
6108 93316 --clk3;
6109 93316 move(step);
6110 94563 }
6111
6112 // the variable speed floater movement
6113 // ms is max speed
6114 // ss is step speed
6115 // s is step count
6116 // p is pause count
6117 // g is graduality :)
6118 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6119 3989892 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6120 {
6121 3989892 ++clk2;
6122 3989892 byte over_pit = overpit(this);
6123
6124
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2875098 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
3989892 if(dmisc1 && over_pit) p = 0;
6125
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56213 times.
✓ Branch 2 taken 1570783 times.
✓ Branch 3 taken 2230728 times.
✓ Branch 4 taken 132168 times.
3989892 switch(movestatus)
6126 {
6127 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6128 //! if the conditions prevent it, we jump back to case 2.
6129 case 0: // paused
6130
2/2
✓ Branch 0 taken 54765 times.
✓ Branch 1 taken 1448 times.
56213 if(clk2>=p)
6131 {
6132 1448 movestatus=1;
6133 1448 clk2=0;
6134 1448 }
6135
6136 56213 break;
6137
6138 case 1: // speeding up
6139
1/2
✓ Branch 0 taken 1570783 times.
✗ Branch 1 not taken.
1570783 if (s >= 0)
6140 {
6141
2/2
✓ Branch 0 taken 1559550 times.
✓ Branch 1 taken 11233 times.
1570783 if(clk2<g*s)
6142 {
6143
2/2
✓ Branch 0 taken 1458948 times.
✓ Branch 1 taken 100602 times.
1559550 if(!((clk2-1)%g))
6144 100602 step+=ss;
6145 1559550 }
6146 else
6147 {
6148 11233 movestatus=2;
6149 11233 clk2=0;
6150 }
6151 1570783 }
6152 else
6153 {
6154 if(step < ms)
6155 {
6156 if(!((clk2-1)%g))
6157 {
6158 step+=ss;
6159 if (step >= ms) step = ms;
6160 }
6161 }
6162 else
6163 {
6164 step = ms;
6165 movestatus=2;
6166 clk2=0;
6167 }
6168 }
6169
6170 1570783 break;
6171
6172 case 2: // normal
6173 2230728 step=ms;
6174
6175
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2230728 times.
✓ Branch 2 taken 477682 times.
✓ Branch 3 taken 1753046 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1753046 times.
✓ Branch 6 taken 1750807 times.
✓ Branch 7 taken 2239 times.
2230728 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6176 {
6177
1/2
✓ Branch 0 taken 2239 times.
✗ Branch 1 not taken.
2239 if (s >= 0) step=ss*s;
6178 else step=ms;
6179 2239 movestatus=3;
6180 2239 clk2=0;
6181 2239 }
6182
6183 2230728 break;
6184
6185 case 3: // slowing down
6186
1/2
✓ Branch 0 taken 132168 times.
✗ Branch 1 not taken.
132168 if (s >= 0)
6187 {
6188
2/2
✓ Branch 0 taken 130491 times.
✓ Branch 1 taken 1677 times.
132168 if(clk2<=g*s)
6189 {
6190 { //don't slow down over pits
6191
6192
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 130224 times.
130491 if(over_pit)
6193 {
6194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6195 {
6196 step=ms;
6197 }
6198 267 }
6199 else //can slow down
6200 {
6201
4/4
✓ Branch 0 taken 8036 times.
✓ Branch 1 taken 122188 times.
✓ Branch 2 taken 7668 times.
✓ Branch 3 taken 368 times.
130224 if(!(clk2%g) && !dmisc1)
6202 7668 step-=ss;
6203 }
6204 }
6205
6206
6207 130491 }
6208 else
6209 {
6210 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6211 //this doesn't help keese, as they have a z of 0.
6212 //they always nee to run this check.
6213 {
6214
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1677 if(over_pit &&!dmisc1)
6215 {
6216 --clk2; //if over a pit, don't land, and revert clock change
6217 }
6218 else //can land safely
6219 {
6220 1677 movestatus=0;
6221
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1677 if(dmisc1&&!over_pit)
6222 1115 step=0;
6223 1677 clk2=0;
6224 }
6225 }
6226
6227 }
6228 132168 }
6229 else
6230 {
6231 if(step > 0)
6232 {
6233 if(over_pit)
6234 {
6235 if(dmisc1)
6236 {
6237 step=ms;
6238 }
6239 }
6240 else //can slow down
6241 {
6242 if(!(clk2%g))
6243 step-=ss;
6244 }
6245 }
6246 else
6247 {
6248 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6249 //this doesn't help keese, as they have a z of 0.
6250 //they always nee to run this check.
6251 if(over_pit)
6252 {
6253 step+=ss; //if over a pit, don't land, and revert clock change
6254 }
6255 else //can land safely
6256 {
6257 movestatus=0;
6258 step=0;
6259 clk2=0;
6260 }
6261 }
6262 }
6263
6264 132168 break;
6265 }
6266
6267
2/2
✓ Branch 0 taken 2239722 times.
✓ Branch 1 taken 1750170 times.
3989892 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6268 3989892 }
6269
6270 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6271 {
6272 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6273 }
6274
6275 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6276 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6277 923665 int32_t enemy::lined_up(int32_t range, bool dir8)
6278 {
6279 923665 int32_t lx = Hero.getX();
6280 923665 int32_t ly = Hero.getY();
6281
6282
2/2
✓ Branch 0 taken 38487 times.
✓ Branch 1 taken 885178 times.
923665 if(abs(lx-int32_t(x))<=range)
6283 {
6284
2/2
✓ Branch 0 taken 16116 times.
✓ Branch 1 taken 22371 times.
38487 if(ly<y)
6285 {
6286 16116 return up;
6287 }
6288
6289 22371 return down;
6290 }
6291
6292
2/2
✓ Branch 0 taken 56294 times.
✓ Branch 1 taken 828884 times.
885178 if(abs(ly-int32_t(y))<=range)
6293 {
6294
2/2
✓ Branch 0 taken 30277 times.
✓ Branch 1 taken 26017 times.
56294 if(lx<x)
6295 {
6296 30277 return left;
6297 }
6298
6299 26017 return right;
6300 }
6301
6302
2/2
✓ Branch 0 taken 159834 times.
✓ Branch 1 taken 669050 times.
828884 if(dir8)
6303 {
6304
2/2
✓ Branch 0 taken 252160 times.
✓ Branch 1 taken 416890 times.
669050 if(abs(lx-x)-abs(ly-y)<=range)
6305 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6306 {
6307
2/2
✓ Branch 0 taken 105160 times.
✓ Branch 1 taken 147000 times.
252160 if(ly<y)
6308 {
6309
2/2
✓ Branch 0 taken 56622 times.
✓ Branch 1 taken 48538 times.
105160 if(lx<x)
6310 {
6311 56622 return l_up;
6312 }
6313 else
6314 {
6315 48538 return r_up;
6316 }
6317 }
6318 else
6319 {
6320
2/2
✓ Branch 0 taken 76220 times.
✓ Branch 1 taken 70780 times.
147000 if(lx<x)
6321 {
6322 70780 return l_down;
6323 }
6324 else
6325 {
6326 76220 return r_down;
6327 }
6328 }
6329 }
6330 416890 }
6331
6332 576724 return -1;
6333 923665 }
6334
6335 // returns true if Hero is within 'range' pixels of the enemy
6336 27884 bool enemy::HeroInRange(int32_t range)
6337 {
6338 27884 int32_t lx = Hero.getX();
6339 27884 int32_t ly = Hero.getY();
6340
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6341 }
6342
6343 // place the enemy in line with Hero (red wizzrobes)
6344 4858 void enemy::place_on_axis(bool floater, bool solid_ok)
6345 {
6346
6/6
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 4285 times.
✓ Branch 2 taken 4316 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 573 times.
✓ Branch 5 taken 3743 times.
4858 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6347
6/6
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 4421 times.
✓ Branch 2 taken 4082 times.
✓ Branch 3 taken 776 times.
✓ Branch 4 taken 437 times.
✓ Branch 5 taken 3645 times.
4858 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6348 4858 int32_t pos2=zc_oldrand()%23;
6349 4858 int32_t tried=0;
6350 4858 bool last_resort,placed=false;
6351
6352
6353 4858 do
6354 {
6355
2/2
✓ Branch 0 taken 4432 times.
✓ Branch 1 taken 3104 times.
7536 if(pos2<14)
6356 {
6357 4432 x=(pos2<<4)+16;
6358 4432 y=ly;
6359 4432 }
6360 else
6361 {
6362 3104 x=lx;
6363 3104 y=((pos2-14)<<4)+16;
6364 }
6365
6366 // Don't commit to a last resort if position is out of bounds.
6367
6/6
✓ Branch 0 taken 7199 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6889 times.
✓ Branch 3 taken 310 times.
✓ Branch 4 taken 255 times.
✓ Branch 5 taken 6634 times.
7536 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6368
6369
4/4
✓ Branch 0 taken 3879 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 4912 times.
✓ Branch 3 taken 1443 times.
7536 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6370 {
6371 // Red Wizzrobes should be able to appear on water, but not other
6372 // solid combos; however, they could appear on solid combos in 2.10,
6373 // and some quests depend on that.
6374
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6228 times.
✓ Branch 2 taken 1370 times.
✓ Branch 3 taken 4858 times.
8569 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6375 8569 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6376 4858 placed=true;
6377 8569 }
6378
6379
3/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7340 if(!placed && tried>=22 && last_resort)
6380 {
6381 placed=true;
6382 }
6383
6384 7340 ++tried;
6385 7340 pos2=(pos2+3)%23;
6386
2/2
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
7340 }
6387 7340 while(!placed);
6388
6389
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 1790 times.
4662 if(y==ly)
6390 2872 dir=(x<lx)?right:left;
6391 else
6392 1790 dir=(y<ly)?down:up;
6393
6394 4662 clk2=tried;
6395 4662 }
6396
6397 20213685 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6398 {
6399 20213685 int32_t t = o_tile;
6400 20213685 int32_t b = o_tile;
6401
6402 // Darknuts, but also Wizzrobes and Wallmasters
6403
3/4
✓ Branch 0 taken 8353120 times.
✓ Branch 1 taken 10837883 times.
✓ Branch 2 taken 1022682 times.
✗ Branch 3 not taken.
20213685 switch(family)
6404 {
6405 case eeWALK:
6406
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10332476 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10837883 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6407 {
6408 367468 tile=s_tile;
6409 367468 t=s_tile;
6410 367468 b=s_tile;
6411 367468 }
6412
6413 10837883 break;
6414
6415 case eeTRAP:
6416
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 829116 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1022682 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
6417 {
6418 193566 tile=s_tile;
6419 193566 t=s_tile;
6420 193566 b=s_tile;
6421 193566 }
6422
6423 1022682 break;
6424
6425 case eeSPINTILE:
6426 if(misc>=96 && do_animation)
6427 {
6428 tile=o_tile+frames*ndir;
6429 t=tile;
6430 }
6431
6432 break;
6433 }
6434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20213685 times.
20213685 if ( do_animation )
6435 {
6436
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20016643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19749512 times.
20213685 if(ndir!=0) switch(frames)
6437 {
6438 case 2:
6439 267131 tiledir_small(dir,ndir==4);
6440 267131 break;
6441
6442 case 3:
6443 tiledir_three(dir);
6444 break;
6445
6446 case 4:
6447 19749512 tiledir(dir,ndir==4);
6448 19749512 break;
6449 20016643 }
6450
6451
2/2
✓ Branch 0 taken 10837883 times.
✓ Branch 1 taken 9375802 times.
20213685 if(family==eeWALK)
6452
6/6
✓ Branch 0 taken 10776874 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8177902 times.
✓ Branch 3 taken 2659981 times.
✓ Branch 4 taken 2644258 times.
✓ Branch 5 taken 15723 times.
10837883 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6453 else
6454 9375802 tile+=f4;
6455 20213685 }
6456 20213685 return b;
6457 }
6458
6459 void enemy::tiledir_three(int32_t ndir)
6460 {
6461 if ( !do_animation ) return;
6462 flip=0;
6463
6464 switch(ndir)
6465 {
6466 case right:
6467 tile+=3;
6468 [[fallthrough]];
6469
6470 case left:
6471 tile+=3;
6472 [[fallthrough]];
6473
6474 case down:
6475 tile+=3;
6476 [[fallthrough]];
6477
6478 case up:
6479 break;
6480 }
6481 }
6482
6483 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6484 {
6485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6486 267131 flip=0;
6487
6488
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6489 {
6490 case 8:
6491 case up:
6492 53829 break;
6493
6494 case 12:
6495 case down:
6496 54679 tile+=2;
6497 54679 break;
6498
6499 case 14:
6500 case left:
6501 67727 tile+=4;
6502 67727 break;
6503
6504 case 10:
6505 case right:
6506 71182 tile+=6;
6507 71182 break;
6508
6509 case 9:
6510 case r_up:
6511
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6512 5706 break;
6513
6514 tile+=10;
6515 break;
6516
6517 case 11:
6518 case r_down:
6519
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6520 5154 tile+=2;
6521 else
6522 tile+=14;
6523
6524 5154 break;
6525
6526 case 13:
6527 case l_down:
6528
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6529 4872 tile+=2;
6530 else
6531 tile+=12;
6532
6533 4872 break;
6534
6535 case 15:
6536 case l_up:
6537
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6538 3982 break;
6539
6540 tile+=8;
6541 break;
6542
6543 default:
6544 //dir=(zc_oldrand()*100)%8;
6545 //tiledir_small(dir);
6546 // flip=zc_oldrand()&3;
6547 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6548 break;
6549 }
6550 267131 }
6551
6552 23069632 void enemy::tiledir(int32_t ndir, bool fourdir)
6553 {
6554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23069632 times.
23069632 if ( !do_animation ) return;
6555 23069632 flip=0;
6556
6557
9/9
✓ Branch 0 taken 4483892 times.
✓ Branch 1 taken 4141765 times.
✓ Branch 2 taken 5412757 times.
✓ Branch 3 taken 5175571 times.
✓ Branch 4 taken 825768 times.
✓ Branch 5 taken 1018734 times.
✓ Branch 6 taken 1099241 times.
✓ Branch 7 taken 845055 times.
✓ Branch 8 taken 66849 times.
23069632 switch(ndir)
6558 {
6559 case 8:
6560 case up:
6561 4483892 break;
6562
6563 case 12:
6564 case down:
6565 4141765 tile+=4;
6566 4141765 break;
6567
6568 case 14:
6569 case left:
6570 5412757 tile+=8;
6571 5412757 break;
6572
6573 case 10:
6574 case right:
6575 5175571 tile+=12;
6576 5175571 break;
6577
6578 case 9:
6579 case r_up:
6580
2/2
✓ Branch 0 taken 88653 times.
✓ Branch 1 taken 737115 times.
825768 if(fourdir)
6581 88653 break;
6582 else
6583 737115 tile+=24;
6584
6585 737115 break;
6586
6587 case 11:
6588 case r_down:
6589
2/2
✓ Branch 0 taken 101949 times.
✓ Branch 1 taken 916785 times.
1018734 if(fourdir)
6590 101949 tile+=4;
6591 else
6592 916785 tile+=32;
6593
6594 1018734 break;
6595
6596 case 13:
6597 case l_down:
6598
2/2
✓ Branch 0 taken 105945 times.
✓ Branch 1 taken 993296 times.
1099241 if(fourdir)
6599 105945 tile+=4;
6600 else
6601 993296 tile+=28;
6602
6603 1099241 break;
6604
6605 case 15:
6606 case l_up:
6607
2/2
✓ Branch 0 taken 82760 times.
✓ Branch 1 taken 762295 times.
845055 if(fourdir)
6608 82760 break;
6609 else
6610 762295 tile+=20;
6611
6612 762295 break;
6613
6614 default:
6615 //dir=(zc_oldrand()*100)%8;
6616 //tiledir(dir);
6617 // flip=zc_oldrand()&3;
6618 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6619 66849 break;
6620 }
6621 23069632 }
6622
6623 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6624 {
6625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6626 3868 flip=0;
6627
6628
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6629 {
6630 case 8:
6631 case up:
6632 297 break;
6633
6634 case 12:
6635 case down:
6636 tile+=8;
6637 break;
6638
6639 case 14:
6640 case left:
6641 195 tile+=40;
6642 195 break;
6643
6644 case 10:
6645 case right:
6646 179 tile+=48;
6647 179 break;
6648
6649 case 9:
6650 case r_up:
6651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6652 break;
6653
6654 306 tile+=88;
6655 306 break;
6656
6657 case 11:
6658 case r_down:
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6660 tile+=8;
6661 else
6662 1235 tile+=128;
6663
6664 1235 break;
6665
6666 case 13:
6667 case l_down:
6668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6669 tile+=8;
6670 else
6671 1324 tile+=120;
6672
6673 1324 break;
6674
6675 case 15:
6676 case l_up:
6677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6678 break;
6679
6680 332 tile+=80;
6681 332 break;
6682
6683 default:
6684 //dir=(zc_oldrand()*100)%8;
6685 //tiledir_big(dir);
6686 // flip=zc_oldrand()&3;
6687 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6688 break;
6689 }
6690 3868 }
6691
6692 39887439 void enemy::update_enemy_frame()
6693 {
6694
4/4
✓ Branch 0 taken 39885133 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 39885126 times.
39887439 if(fallclk||drownclk) return;
6695
1/2
✓ Branch 0 taken 39885126 times.
✗ Branch 1 not taken.
39885126 if (!do_animation)
6696 return;
6697
6698
4/4
✓ Branch 0 taken 1475966 times.
✓ Branch 1 taken 38409160 times.
✓ Branch 2 taken 1473959 times.
✓ Branch 3 taken 2007 times.
39885126 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6699
6700
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39885126 if(get_qr(qr_ANONE_NOANIM)
6701
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39885126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39885126 && anim == aNONE && family != eeGUY)
6702 return;
6703
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39513750 times.
39885126 int32_t newfrate = zc_max(frate,4);
6704 39885126 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6705 39885126 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6706
2/2
✓ Branch 0 taken 29892424 times.
✓ Branch 1 taken 9992702 times.
39885126 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6707 39885126 tile = o_tile;
6708 39885126 int32_t basetile = o_tile;
6709 39885126 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6710 39885126 bool ignore_extend = false;
6711
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 201257 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4974474 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1519575 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 686882 times.
✓ Branch 22 taken 1691672 times.
✓ Branch 23 taken 1133827 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4117708 times.
✓ Branch 27 taken 7475916 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582791 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880199 times.
✓ Branch 32 taken 218668 times.
✓ Branch 33 taken 1812060 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 6953976 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
39885126 switch(anim)
6712 {
6713
6714 case aDONGO:
6715 {
6716 69324 int32_t fr = stunclk>0 ? 16 : 8;
6717
6718
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6719 {
6720 // bloated
6721
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6722 {
6723 case up:
6724 960 tile+=9;
6725 960 flip=0;
6726 960 xofs=0;
6727 960 dummy_int[1]=0; //no additional tiles
6728 960 break;
6729
6730 case down:
6731 960 tile+=7;
6732 960 flip=0;
6733 960 xofs=0;
6734 960 dummy_int[1]=0; //no additional tiles
6735 960 break;
6736
6737 case left:
6738 1664 flip=1;
6739 1664 tile+=4;
6740 1664 xofs=16;
6741 1664 dummy_int[1]=1; //second tile is next tile
6742 1664 break;
6743
6744 case right:
6745 896 flip=0;
6746 896 tile+=5;
6747 896 xofs=16;
6748 896 dummy_int[1]=-1; //second tile is previous tile
6749 896 break;
6750 }
6751 4480 }
6752
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6753 {
6754 // normal
6755
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6756 {
6757 case up:
6758 13652 tile+=8;
6759 13652 flip=(clk&fr)?1:0;
6760 13652 xofs=0;
6761 13652 dummy_int[1]=0; //no additional tiles
6762 13652 break;
6763
6764 case down:
6765 15374 tile+=6;
6766 15374 flip=(clk&fr)?1:0;
6767 15374 xofs=0;
6768 15374 dummy_int[1]=0; //no additional tiles
6769 15374 break;
6770
6771 case left:
6772 19615 flip=1;
6773 19615 tile+=(clk&fr)?2:0;
6774 19615 xofs=16;
6775 19615 dummy_int[1]=1; //second tile is next tile
6776 19615 break;
6777
6778 case right:
6779 15086 flip=0;
6780 15086 tile+=(clk&fr)?3:1;
6781 15086 xofs=16;
6782 15086 dummy_int[1]=-1; //second tile is next tile
6783 15086 break;
6784 }
6785 63727 }
6786 }
6787 69324 break;
6788
6789 case aNEWDONGO:
6790 {
6791 53456 int32_t fr4=0;
6792
6793
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6794 {
6795 // bloated
6796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6797 {
6798 2752 fr4=3;
6799 2752 }
6800
6801
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6802 {
6803 2107 fr4=2;
6804 2107 }
6805
6806
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6807 {
6808 1419 fr4=1;
6809 1419 }
6810
6811
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6812 {
6813 731 fr4=0;
6814 731 }
6815
6816
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6817 {
6818 case up:
6819 256 xofs=0;
6820 256 tile+=8+fr4;
6821 256 dummy_int[1]=0; //no additional tiles
6822 256 break;
6823
6824 case down:
6825 576 xofs=0;
6826 576 tile+=12+fr4;
6827 576 dummy_int[1]=0; //no additional tiles
6828 576 break;
6829
6830 case left:
6831 704 tile+=29+(2*fr4);
6832 704 xofs=16;
6833 704 dummy_int[1]=-1; //second tile is previous tile
6834 704 break;
6835
6836 case right:
6837 1216 tile+=49+(2*fr4);
6838 1216 xofs=16;
6839 1216 dummy_int[1]=-1; //second tile is previous tile
6840 1216 break;
6841 }
6842 2752 }
6843
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6844 {
6845 // normal
6846
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6847 {
6848 case up:
6849 9234 xofs=0;
6850 9234 tile+=((clk&12)>>2);
6851 9234 dummy_int[1]=0; //no additional tiles
6852 9234 break;
6853
6854 case down:
6855 9871 xofs=0;
6856 9871 tile+=4+((clk&12)>>2);
6857 9871 dummy_int[1]=0; //no additional tiles
6858 9871 break;
6859
6860 case left:
6861 15025 tile+=21+((clk&12)>>1);
6862 15025 xofs=16;
6863 15025 dummy_int[1]=-1; //second tile is previous tile
6864 15025 break;
6865
6866 case right:
6867 15676 flip=0;
6868 15676 tile+=41+((clk&12)>>1);
6869 15676 xofs=16;
6870 15676 dummy_int[1]=-1; //second tile is previous tile
6871 15676 break;
6872 }
6873 49806 }
6874 }
6875 53456 break;
6876
6877 case aDONGOBS:
6878 {
6879 38833 int32_t fr4=0;
6880
6881
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6882 {
6883 // bloated
6884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6885 {
6886 2688 fr4=3;
6887 2688 }
6888
6889
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6890 {
6891 2058 fr4=2;
6892 2058 }
6893
6894
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6895 {
6896 1386 fr4=1;
6897 1386 }
6898
6899
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6900 {
6901 714 fr4=0;
6902 714 }
6903
6904
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6905 {
6906 case up:
6907 256 tile+=28+fr4;
6908 256 yofs+=8;
6909 256 dummy_int[1]=-20; //second tile change
6910 256 dummy_int[2]=0; //new xofs change
6911 256 dummy_int[3]=-16; //new xofs change
6912 256 break;
6913
6914 case down:
6915 384 tile+=12+fr4;
6916 384 yofs-=8;
6917 384 dummy_int[1]=20; //second tile change
6918 384 dummy_int[2]=0; //new xofs change
6919 384 dummy_int[3]=16; //new xofs change
6920 384 break;
6921
6922 case left:
6923 1024 tile+=49+(2*fr4);
6924 1024 xofs+=8;
6925 1024 dummy_int[1]=-1; //second tile change
6926 1024 dummy_int[2]=-16; //new xofs change
6927 1024 dummy_int[3]=0; //new xofs change
6928 1024 break;
6929
6930 case right:
6931 1024 tile+=69+(2*fr4);
6932 1024 xofs+=8;
6933 1024 dummy_int[1]=-1; //second tile change
6934 1024 dummy_int[2]=-16; //new xofs change
6935 1024 dummy_int[3]=0; //new xofs change
6936 1024 break;
6937 }
6938 2688 }
6939
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6940 {
6941 // normal
6942
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6943 {
6944 case up:
6945 7136 tile+=20+((clk&24)>>3);
6946 7136 yofs+=8;
6947 7136 dummy_int[1]=-20; //second tile change
6948 7136 dummy_int[2]=0; //new xofs change
6949 7136 dummy_int[3]=-16; //new xofs change
6950 7136 break;
6951
6952 case down:
6953 6672 tile+=4+((clk&24)>>3);
6954 6672 yofs-=8;
6955 6672 dummy_int[1]=20; //second tile change
6956 6672 dummy_int[2]=0; //new xofs change
6957 6672 dummy_int[3]=16; //new xofs change
6958 6672 break;
6959
6960 case left:
6961 11075 xofs=-8;
6962 11075 tile+=40+((clk&24)>>2);
6963 11075 dummy_int[1]=1; //second tile change
6964 11075 dummy_int[2]=16; //new xofs change
6965 11075 dummy_int[3]=0; //new xofs change
6966 11075 break;
6967
6968 case right:
6969 10601 tile+=60+((clk&24)>>2);
6970 10601 xofs=-8;
6971 10601 dummy_int[1]=1; //second tile change
6972 10601 dummy_int[2]=16; //new xofs change
6973 10601 dummy_int[3]=0; //new xofs change
6974 10601 break;
6975 }
6976 35484 }
6977 }
6978 38833 break;
6979
6980 case aWIZZ:
6981 {
6982 // if(d->misc1)
6983
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6984 {
6985
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6986 {
6987 91127 ++tile;
6988 91127 }
6989 182184 }
6990 else
6991 {
6992
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6993 {
6994 136489 ++tile;
6995 136489 }
6996 }
6997
6998
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6999 {
7000 case 9:
7001 case 15:
7002 case up:
7003 76094 tile+=2;
7004 76094 break;
7005
7006 case down:
7007 76591 break;
7008
7009 case 13:
7010 case left:
7011 157108 flip=1;
7012 157108 break;
7013
7014 default:
7015 145581 flip=0;
7016 145581 break;
7017 }
7018 }
7019 455374 break;
7020
7021 case aNEWWIZZ:
7022 {
7023 1519575 tiledir(dir,true);
7024
7025 // if(d->misc1) //walking wizzrobe
7026
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 777151 times.
1519575 if(dmisc1) //walking wizzrobe
7027 {
7028
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7029 {
7030 369103 tile+=2;
7031 369103 }
7032
7033
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7034 {
7035 370339 tile+=1;
7036 370339 }
7037
7038
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7039 {
7040
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7041 {
7042 79162 tile+=40;
7043 79162 }
7044 742424 }
7045 742424 }
7046 else
7047 {
7048
4/4
✓ Branch 0 taken 710492 times.
✓ Branch 1 taken 66659 times.
✓ Branch 2 taken 167559 times.
✓ Branch 3 taken 542933 times.
777151 if(dummy_bool[1]||dummy_bool[2])
7049 {
7050 234218 tile+=20;
7051
7052
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 167568 times.
234218 if(dummy_bool[2])
7053 {
7054 167568 tile+=20;
7055 167568 }
7056 234218 }
7057
7058 777151 tile+=((frame>>1)&3);
7059 }
7060 }
7061 1519575 break;
7062
7063 case a3FRM:
7064 {
7065
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7066 }
7067 197042 break;
7068
7069 case a3FRM4DIR:
7070 {
7071 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7072 }
7073 break;
7074
7075 case aVIRE:
7076 {
7077
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7078 {
7079 29292 tile+=2;
7080 29292 }
7081
7082 128880 tile+=fx;
7083 }
7084 128880 break;
7085
7086 case aROPE:
7087 {
7088 220021 tile+=(1-fx);
7089 220021 flip = dir==left ? 1:0;
7090 }
7091 220021 break;
7092
7093 case aZORA:
7094 {
7095 int32_t dl;
7096
7097
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7098 {
7099 46739 dl=clk+5;
7100 46739 goto waves2;
7101 }
7102
7103
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7104
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7105 else
7106 {
7107 92458 dl=clk-36-66;
7108 waves2:
7109 139197 tile=((dl/11)&1)+s_tile;
7110 139197 basetile = s_tile;
7111 }
7112 }
7113 221637 break;
7114
7115 case aNEWZORA:
7116 {
7117 686882 f4=(clk/16)%4;
7118
7119 686882 tiledir(dir,true);
7120 int32_t dl;
7121
7122
4/4
✓ Branch 0 taken 485838 times.
✓ Branch 1 taken 201044 times.
✓ Branch 2 taken 249250 times.
✓ Branch 3 taken 236588 times.
686882 if((clk>35)&&(clk<36+67)) //surfaced
7123 {
7124
4/4
✓ Branch 0 taken 202239 times.
✓ Branch 1 taken 34349 times.
✓ Branch 2 taken 29164 times.
✓ Branch 3 taken 173075 times.
236588 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7125 {
7126 173075 tile+=80;
7127 173075 } //mouth closed
7128 else
7129 {
7130 63513 tile+=40;
7131 }
7132
7133 236588 tile+=f4;
7134 236588 }
7135 else
7136 {
7137
2/2
✓ Branch 0 taken 201044 times.
✓ Branch 1 taken 249250 times.
450294 if(clk<36)
7138 {
7139 201044 dl=clk+5;
7140 201044 }
7141 else
7142 {
7143 249250 dl=clk-36-66;
7144 }
7145
7146 450294 tile+=((dl/5)&3);
7147 }
7148 }
7149 686882 break;
7150
7151 case a4FRM4EYE:
7152 case a2FRM4EYE:
7153 case a4FRM8EYE:
7154 case a4FRM8EYEB: //big version
7155 case a4FRM4EYEB:
7156 {
7157 836734 tilerows = 2;
7158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7160 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7161 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7162 836734 int32_t lookat=zc_oldrand()&15;
7163
7164
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7165 {
7166 210774 lookat=l_down;
7167 210774 }
7168
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7169 {
7170 226850 lookat=down;
7171 226850 }
7172
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7173 {
7174 108837 lookat=r_down;
7175 108837 }
7176
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7177 {
7178 70395 lookat=right;
7179 70395 }
7180
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7181 {
7182 35067 lookat=r_up;
7183 35067 }
7184
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7185 {
7186 25436 lookat=up;
7187 25436 }
7188
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7189 {
7190 36803 lookat=l_up;
7191 36803 }
7192 else
7193 {
7194 122572 lookat=left;
7195 }
7196
7197 836734 int32_t dir2 = dir;
7198 836734 dir = lookat;
7199
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7200 else
7201 {
7202 tiledir_big(dir,(anim == a4FRM4EYEB));
7203 tile+=2*f4;
7204 ignore_extend = true;
7205 }
7206 836734 dir = dir2;
7207 }
7208 836734 break;
7209
7210 case aFLIP:
7211 {
7212 1691672 flip = f2&1;
7213 }
7214 1691672 break;
7215
7216 case a2FRM:
7217 {
7218 1133827 tile += (1-f2);
7219 }
7220 1133827 break;
7221
7222 case a2FRMB:
7223 {
7224 tile+= 2*(1-f2);
7225 ignore_extend = true;
7226 }
7227 break;
7228
7229 case a2FRM4DIR:
7230 {
7231 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7232 }
7233 267131 break;
7234
7235 case a4FRM4DIRF:
7236 {
7237 4117708 basetile = n_frame_n_dir(4,4,f4);
7238
7239
2/2
✓ Branch 0 taken 2717716 times.
✓ Branch 1 taken 1399992 times.
4117708 if(clk2>0) //stopped to fire
7240 {
7241 1399992 tile+=20;
7242
7243
2/2
✓ Branch 0 taken 697526 times.
✓ Branch 1 taken 702466 times.
1399992 if(clk2<17) //firing
7244 {
7245 702466 tile+=20;
7246 702466 }
7247 1399992 }
7248 }
7249 4117708 break;
7250
7251 case a4FRM4DIR:
7252 {
7253 7475916 basetile = n_frame_n_dir(4,4,f4);
7254 }
7255 7475916 break;
7256
7257 case a4FRM8DIRF:
7258 {
7259 tilerows = 2;
7260 basetile = n_frame_n_dir(4,8,f4);
7261
7262 if(clk2>0) //stopped to fire
7263 {
7264 tile+=40;
7265
7266 if(clk2<17) //firing
7267 {
7268 tile+=40;
7269 }
7270 }
7271 }
7272 break;
7273
7274 case a4FRM8DIRB:
7275 case a4FRM8DIRFB:
7276 {
7277 3868 tilerows = 2;
7278 3868 tiledir_big(dir,false);
7279 3868 tile+=2*f4;
7280
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7281 {
7282 tile+=80;
7283
7284 if(clk2<17) //firing
7285 {
7286 tile+=80;
7287 }
7288 }
7289 3868 ignore_extend = true;
7290 }
7291 3868 break;
7292
7293 case a4FRM4DIRB:
7294 case a4FRM4DIRFB:
7295 {
7296 tilerows = 2;
7297 tiledir_big(dir,true);
7298 tile+=2*f4;
7299 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7300 {
7301 tile+=40;
7302
7303 if(clk2<17) //firing
7304 {
7305 tile+=40;
7306 }
7307 }
7308 ignore_extend = true;
7309 }
7310 break;
7311
7312 case aOCTO:
7313 {
7314
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165605 times.
✓ Branch 4 taken 157127 times.
582791 switch(dir)
7315 {
7316 case up:
7317 122459 flip = 2;
7318 122459 break;
7319
7320 case down:
7321 133448 flip = 0;
7322 133448 break;
7323
7324 case left:
7325 165605 flip = 0;
7326 165605 tile += 2;
7327 165605 break;
7328
7329 case right:
7330 157127 flip = 1;
7331 157127 tile += 2;
7332 157127 break;
7333 }
7334
7335 582791 tile+=f2;
7336 }
7337 582791 break;
7338
7339 case aWALK:
7340 {
7341
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7342 {
7343 case up:
7344 248704 tile+=3;
7345 248704 flip = f2;
7346 248704 break;
7347
7348 case down:
7349 267165 tile+=2;
7350 267165 flip = f2;
7351 267165 break;
7352
7353 case left:
7354 331694 flip=1;
7355 331694 tile += f2;
7356 331694 break;
7357
7358 case right:
7359 325802 flip=0;
7360 325802 tile += f2;
7361 325802 break;
7362 }
7363 }
7364 1178979 break;
7365
7366 case aDWALK:
7367 {
7368
3/4
✓ Branch 0 taken 92353 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92353 times.
✗ Branch 3 not taken.
880199 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7369 {
7370 tile=s_tile;
7371 basetile = s_tile;
7372 }
7373
7374
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260962 times.
✓ Branch 4 taken 255928 times.
880199 switch(dir)
7375 {
7376 case up:
7377 177728 tile+=2;
7378 177728 flip=f2;
7379 177728 break;
7380
7381 case down:
7382 185581 flip=0;
7383 185581 tile+=(1-f2);
7384 185581 break;
7385
7386 case left:
7387 260962 flip=1;
7388 260962 tile+=(3+f2);
7389 260962 break;
7390
7391 case right:
7392 255928 flip=0;
7393 255928 tile+=(3+f2);
7394 255928 break;
7395 }
7396 }
7397 880199 break;
7398
7399 case aTEK:
7400 {
7401
2/2
✓ Branch 0 taken 139654 times.
✓ Branch 1 taken 79014 times.
218668 if(misc==0)
7402 {
7403 79014 tile += f2;
7404 79014 }
7405
2/2
✓ Branch 0 taken 72936 times.
✓ Branch 1 taken 66718 times.
139654 else if(misc!=1)
7406 {
7407 66718 ++tile;
7408 66718 }
7409 }
7410 218668 break;
7411
7412 case aNEWTEK:
7413 {
7414
2/2
✓ Branch 0 taken 474700 times.
✓ Branch 1 taken 1337360 times.
1812060 if(step<0) //up
7415 {
7416
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235321 times.
✓ Branch 2 taken 239379 times.
474700 switch(clk3)
7417 {
7418 case left:
7419 235321 flip=0;
7420 235321 tile+=20;
7421 235321 break;
7422
7423 case right:
7424 239379 flip=0;
7425 239379 tile+=24;
7426 239379 break;
7427 }
7428 474700 }
7429
2/2
✓ Branch 0 taken 54741 times.
✓ Branch 1 taken 1282619 times.
1337360 else if(step==0)
7430 {
7431
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40562 times.
✓ Branch 2 taken 14179 times.
54741 switch(clk3)
7432 {
7433 case left:
7434 40562 flip=0;
7435 40562 tile+=8;
7436 40562 break;
7437
7438 case right:
7439 14179 flip=0;
7440 14179 tile+=12;
7441 14179 break;
7442 }
7443 54741 } //down
7444 else
7445 {
7446
3/3
✓ Branch 0 taken 104875 times.
✓ Branch 1 taken 592792 times.
✓ Branch 2 taken 584952 times.
1282619 switch(clk3)
7447 {
7448 case left:
7449 592792 flip=0;
7450 592792 tile+=28;
7451 592792 break;
7452
7453 case right:
7454 584952 flip=0;
7455 584952 tile+=32;
7456 584952 break;
7457 }
7458 }
7459
7460
2/2
✓ Branch 0 taken 1232959 times.
✓ Branch 1 taken 579101 times.
1812060 if(misc==0)
7461 {
7462 579101 tile+=f4;
7463 579101 }
7464
2/2
✓ Branch 0 taken 577625 times.
✓ Branch 1 taken 655334 times.
1232959 else if(misc!=1)
7465 {
7466 655334 tile+=2;
7467 655334 }
7468 }
7469 1812060 break;
7470
7471 case aARMOS:
7472 {
7473
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7474 {
7475 5401 tile += fx;
7476
7477
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7478 1197 tile += 2;
7479 5401 }
7480 }
7481 8628 break;
7482
7483 case aARMOS4:
7484 {
7485
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28875 times.
✓ Branch 2 taken 86061 times.
✓ Branch 3 taken 43591 times.
✓ Branch 4 taken 42730 times.
201257 switch(dir)
7486 {
7487 case up:
7488 28875 flip=0;
7489 28875 break;
7490
7491 case down:
7492 86061 flip=0;
7493 86061 tile+=4;
7494 86061 break;
7495
7496 case left:
7497 43591 flip=0;
7498 43591 tile+=8;
7499 43591 break;
7500
7501 case right:
7502 42730 flip=0;
7503 42730 tile+=12;
7504 42730 break;
7505 }
7506
7507
2/2
✓ Branch 0 taken 59739 times.
✓ Branch 1 taken 141518 times.
201257 if(!fading)
7508 {
7509 141518 tile+=f4;
7510 141518 }
7511 }
7512 201257 break;
7513
7514 case aGHINI:
7515 {
7516
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7517 {
7518 case 8:
7519 case 9:
7520 case up:
7521 28037 ++tile;
7522 28037 flip=0;
7523 28037 break;
7524
7525 case 15:
7526 452 ++tile;
7527 452 flip=1;
7528 452 break;
7529
7530 case 10:
7531 case 11:
7532 case right:
7533 32092 flip=1;
7534 32092 break;
7535
7536 default:
7537 72763 flip=0;
7538 72763 break;
7539 }
7540 }
7541 133344 break;
7542
7543 case a2FRMPOS:
7544 {
7545 1755010 tile+=posframe;
7546 }
7547 1755010 break;
7548
7549 case a4FRMPOS4DIR:
7550 {
7551 363745 basetile = n_frame_n_dir(4,4,0);
7552 // tile+=f2;
7553 363745 tile+=posframe;
7554 }
7555 363745 break;
7556
7557 case a4FRMPOS4DIRF:
7558 {
7559 1433 basetile = n_frame_n_dir(4,4,0);
7560
7561
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7562 {
7563 197 tile+=20;
7564
7565
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7566 {
7567 64 tile+=20;
7568 64 }
7569 197 }
7570
7571 // tile+=f2;
7572 1433 tile+=posframe;
7573 }
7574 1433 break;
7575
7576 case a4FRMPOS8DIR:
7577 {
7578 6953976 tilerows = 2;
7579 6953976 int32_t n = tile;
7580 6953976 basetile = n_frame_n_dir(4,8,0);
7581 // tile+=f2;
7582 6953976 tile+=posframe;
7583 }
7584 6953976 break;
7585
7586 case a4FRMPOS8DIRF:
7587 {
7588 tilerows = 2;
7589 basetile = n_frame_n_dir(4,8,0);
7590
7591 if(clk2>0) //stopped to fire
7592 {
7593 tile+=40;
7594
7595 if(clk2<17) //firing
7596 {
7597 tile+=40;
7598 }
7599 }
7600
7601 tile+=posframe;
7602 }
7603 break;
7604
7605 case aNEWLEV:
7606 {
7607 747030 tiledir(dir,true);
7608
7609
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7610 {
7611 case -1:
7612 case 0:
7613 258994 return;
7614
7615 case 1:
7616
7617 // case 5: cs = d->misc2; break;
7618 case 5:
7619 115368 cs = dmisc2;
7620 115368 break;
7621
7622 case 2:
7623 case 4:
7624 48980 tile += 20;
7625 48980 break;
7626
7627 case 3:
7628 323688 tile += 40;
7629 323688 break;
7630 }
7631
7632 488036 tile+=f4;
7633 }
7634 488036 break;
7635
7636 case aLEV:
7637 {
7638 276997 f4 = ((clk/5)&1);
7639
7640
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7641 {
7642 case -1:
7643 case 0:
7644 127945 return;
7645
7646 case 1:
7647
7648 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7649 case 5:
7650 33336 tile += (f2) ? 1 : 0;
7651 33336 cs = dmisc2;
7652 33336 break;
7653
7654 case 2:
7655 case 4:
7656 14658 tile += 2;
7657 14658 break;
7658
7659 case 3:
7660 101058 tile += (f4) ? 4 : 3;
7661 101058 break;
7662 }
7663 }
7664 149052 break;
7665
7666 case aWALLM:
7667 {
7668
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7669 {
7670 139764 tile += f2;
7671 139764 }
7672 }
7673 140514 break;
7674
7675 case aNEWWALLM:
7676 {
7677 366633 int32_t tempdir=0;
7678
7679
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7680 {
7681 case 1:
7682 case 2:
7683 43340 tempdir=clk3;
7684 43340 break;
7685
7686 case 3:
7687 case 4:
7688 case 5:
7689 38855 tempdir=dir;
7690 38855 break;
7691
7692 case 6:
7693 case 7:
7694 8438 tempdir=clk3^1;
7695 8438 break;
7696 }
7697
7698 366633 tiledir(tempdir,true);
7699
7700
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7701 {
7702 364725 tile+=f4;
7703 364725 }
7704 }
7705 366633 break;
7706
7707 case a4FRMNODIR:
7708 {
7709 171508 tile+=f4;
7710 }
7711 171508 break;
7712
7713 } // switch(d->anim)
7714
7715 // flashing
7716 // if(d->flags2 & guy_flashing)
7717
2/2
✓ Branch 0 taken 38754559 times.
✓ Branch 1 taken 743628 times.
39498187 if(flags2 & guy_flashing)
7718 {
7719 743628 cs = (frame&3) + 6;
7720 743628 }
7721
7722
2/2
✓ Branch 0 taken 39087239 times.
✓ Branch 1 taken 410948 times.
39498187 if(flags2&guy_transparent)
7723 {
7724 410948 drawstyle=1;
7725 410948 }
7726
7727 39498187 int32_t change = tile-basetile;
7728
7729
3/6
✓ Branch 0 taken 1936999 times.
✓ Branch 1 taken 37561188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1936999 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39498187 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7730 {
7731
2/2
✓ Branch 0 taken 1673793 times.
✓ Branch 1 taken 263206 times.
1936999 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7732 {
7733 1673793 tile=basetile+txsz*change;
7734 1673793 }
7735 else
7736 {
7737 263206 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7738 }
7739 1936999 }
7740 else
7741 {
7742 37561188 tile=basetile+change;
7743 }
7744 39887439 }
7745
7746 81077 int32_t wpnsfx(int32_t wpn)
7747 {
7748
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21754 times.
✓ Branch 2 taken 665 times.
✓ Branch 3 taken 29990 times.
✓ Branch 4 taken 17706 times.
✓ Branch 5 taken 10962 times.
81077 switch(wpn)
7749 {
7750 case ewFireTrail:
7751 case ewFlame:
7752 case ewFlame2Trail:
7753 case ewFlame2:
7754 21754 return WAV_FIRE;
7755
7756 case ewWind:
7757 case ewMagic:
7758 665 return WAV_WAND;
7759
7760 case ewIce:
7761 return WAV_ZN1ICE;
7762
7763 case ewRock:
7764
2/2
✓ Branch 0 taken 2848 times.
✓ Branch 1 taken 8114 times.
10962 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7765 8114 break;
7766
7767 case ewFireball2:
7768 case ewFireball:
7769
2/2
✓ Branch 0 taken 2646 times.
✓ Branch 1 taken 27344 times.
29990 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7770 27344 }
7771
7772 53164 return -1;
7773 81077 }
7774
7775 76610090 int32_t enemy::run_script(int32_t mode)
7776 {
7777
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76609834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76610090 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7778
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76609834 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76609834 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7779 76609834 return RUNSCRIPT_OK;
7780 auto scrty = *get_scrtype();
7781 auto uid = getUID();
7782 if(!FFCore.doscript(scrty,uid))
7783 return RUNSCRIPT_OK;
7784 int32_t ret = RUNSCRIPT_OK;
7785 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7786 switch(mode)
7787 {
7788 case MODE_NORMAL:
7789 return ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7790 case MODE_WAITDRAW:
7791 if(waitdraw)
7792 {
7793 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7794 waitdraw = false;
7795 }
7796 break;
7797 }
7798 return ret;
7799 76610090 }
7800 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7801 {
7802 return al_map_rgba(255,0,0,opacity);
7803 }
7804 /********************************/
7805 /********* Guy Class **********/
7806 /********************************/
7807
7808 // good guys, fires, fairy, and other non-enemies
7809 // based on enemy class b/c guys in dungeons act sort of like enemies
7810 // also easier to manage all the guys this way
7811 2179 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7812 2179 {
7813 2179 mainguy=mg;
7814 2179 canfreeze=false;
7815 2179 dir=down;
7816
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2179 times.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
2179 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7817 2179 hxofs=2;
7818 2179 hzsz=8;
7819 2179 hit_width=12;
7820 2179 hit_height=17;
7821
7822
10/12
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 766 times.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 744 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 277 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 17 times.
✓ Branch 11 taken 260 times.
2179 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7823 {
7824 1919 superman = 1;
7825 1919 hxofs=1000;
7826 1919 }
7827 2179 }
7828
7829 938381 bool guy::animate(int32_t index)
7830 {
7831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 938381 times.
938381 if(switch_hooked) return enemy::animate(index);
7832
6/6
✓ Branch 0 taken 539203 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 8215 times.
✓ Branch 3 taken 530988 times.
✓ Branch 4 taken 7017 times.
✓ Branch 5 taken 1198 times.
938381 if(mainguy && clk==0 && misc==0)
7833 {
7834 1198 setupscreen();
7835 1198 misc = 1;
7836 1198 }
7837
7838
4/4
✓ Branch 0 taken 539203 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 538875 times.
✓ Branch 3 taken 328 times.
938381 if(mainguy && fadeclk==0)
7839 328 return true;
7840
7841 938053 hp=256; // good guys never die...
7842
7843
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 937131 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
938053 if(hclk && !clk2)
7844 {
7845 // but if they get hit...
7846 16 ++clk2; // only do this once
7847
7848
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7849 {
7850 7 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7851 7 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7852 7 }
7853 16 }
7854
7855 938053 return enemy::animate(index);
7856 938381 }
7857
7858 942518 void guy::draw(BITMAP *dest)
7859 {
7860 942518 update_enemy_frame();
7861
7862
6/6
✓ Branch 0 taken 543133 times.
✓ Branch 1 taken 399385 times.
✓ Branch 2 taken 22779 times.
✓ Branch 3 taken 520354 times.
✓ Branch 4 taken 10998 times.
✓ Branch 5 taken 11781 times.
942518 if(!mainguy || fadeclk<0 || fadeclk&1)
7863 930737 enemy::draw(dest);
7864 942518 }
7865
7866 /*******************************/
7867 /********* Enemies *********/
7868 /*******************************/
7869
7870 763 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7871 763 {
7872 763 clk4=0;
7873 763 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7874 // Spawn type
7875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if(flags & guy_fadeflicker)
7876 {
7877 clk=0;
7878 superman = 1;
7879 fading=fade_flicker;
7880 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7881 dir=down;
7882
7883 if(!canmove(down,(zfix)8,spw_none,false))
7884 clk3=int32_t(13.0/step);
7885 }
7886
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 83 times.
763 else if(flags & guy_fadeinstant)
7887 {
7888 83 clk=0;
7889 83 }
7890 763 SIZEflags = d->SIZEflags;
7891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
763 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7892 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7893 // al_trace("Enemy txsz:%i\n", txsz);
7894
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
763 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7898
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7899
1/2
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
763 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7900 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
763 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7903 {
7904 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
7905 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
7906 }
7907
7908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
7909 763 }
7910
7911 167980 bool eFire::animate(int32_t index)
7912 {
7913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167980 times.
167980 if(switch_hooked) return enemy::animate(index);
7914
2/4
✓ Branch 0 taken 167980 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167980 times.
167980 if(fallclk||drownclk) return enemy::animate(index);
7915
2/2
✓ Branch 0 taken 166188 times.
✓ Branch 1 taken 1792 times.
167980 if(fading)
7916 {
7917
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1791 times.
1792 if(++clk4 > 60)
7918 {
7919 1 clk4=0;
7920 1 superman=0;
7921 1 fading=0;
7922
7923
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags2&cmbflag_armos && z==0 && fakez==0)
7924 removearmos(x,y,ffcactivated);
7925
7926 1 clk2=0;
7927
7928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7929 {
7930 1 dir=0;
7931 1 y = y.getInt() & 0xF0;
7932 1 }
7933
7934 1 return Dead(index);
7935 }
7936
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1791 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
7937 removearmos(x,y,ffcactivated);
7938 1791 }
7939
7940 167979 return enemy::animate(index);
7941 167980 }
7942
7943 352675 void eFire::draw(BITMAP *dest)
7944 {
7945 352675 update_enemy_frame();
7946 352675 enemy::draw(dest);
7947 352675 }
7948
7949 419 int32_t eFire::takehit(weapon *w, weapon* realweap)
7950 {
7951 419 int32_t wpnId = w->id;
7952 419 int32_t wpnDir = w->dir;
7953
7954
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
419 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7955 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
7956 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
7957 {
7958 shield = false;
7959 flags &= ~(inv_left|inv_right|inv_back|inv_front);
7960
7961 if(get_qr(qr_BRKNSHLDTILES))
7962 o_tile=s_tile;
7963 }
7964
7965 419 int32_t ret = enemy::takehit(w,realweap);
7966 419 return ret;
7967 }
7968
7969 void eFire::break_shield()
7970 {
7971 if(!shield)
7972 return;
7973
7974 flags&=~(inv_front | inv_back | inv_left | inv_right);
7975 shield=false;
7976
7977 if(get_qr(qr_BRKNSHLDTILES))
7978 o_tile=s_tile;
7979 }
7980
7981 7297 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7982 7297 {
7983 //zprint2("npct other::other\n");
7984 7297 clk4=0;
7985 7297 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7986
7987 // Spawn type
7988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7297 times.
7297 if(flags & guy_fadeflicker)
7989 {
7990 clk=0;
7991 superman = 1;
7992 fading=fade_flicker;
7993 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7994 dir=down;
7995
7996 if(!canmove(down,(zfix)8,spw_none,false))
7997 clk3=int32_t(13.0/step);
7998 }
7999
2/2
✓ Branch 0 taken 6116 times.
✓ Branch 1 taken 1181 times.
7297 else if(flags & guy_fadeinstant)
8000 {
8001 1181 clk=0;
8002 1181 }
8003 7297 SIZEflags = d->SIZEflags;
8004
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7290 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7297 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8005 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8006 // al_trace("Enemy txsz:%i\n", txsz);
8007
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7290 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
7297 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8008
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
7297 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8009
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
7297 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7297 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7297 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8011
1/2
✓ Branch 0 taken 7297 times.
✗ Branch 1 not taken.
7297 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8012
1/2
✓ Branch 0 taken 7297 times.
✗ Branch 1 not taken.
7297 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8013 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7297 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7297 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7297 times.
7297 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8016 {
8017 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8018 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8019 }
8020
8021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7297 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7297 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8022 7297 }
8023
8024 1864391 bool eOther::animate(int32_t index)
8025 {
8026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1864391 times.
1864391 if(switch_hooked) return enemy::animate(index);
8027
3/4
✓ Branch 0 taken 1862874 times.
✓ Branch 1 taken 1517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1862874 times.
1864391 if(fallclk||drownclk) return enemy::animate(index);
8028 //zprint2("npct other::animate\n");
8029
2/2
✓ Branch 0 taken 1854460 times.
✓ Branch 1 taken 8414 times.
1862874 if(fading)
8030 {
8031
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 8387 times.
8414 if(++clk4 > 60)
8032 {
8033 27 clk4=0;
8034 27 superman=0;
8035 27 fading=0;
8036
8037
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(flags2&cmbflag_armos && z==0 && fakez==0)
8038 removearmos(x,y,ffcactivated);
8039
8040 27 clk2=0;
8041
8042
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!canmove(down,(zfix)8,spw_none,false))
8043 {
8044 2 dir=0;
8045 2 y = y.getInt() & 0xF0;
8046 2 }
8047
8048 27 return Dead(index);
8049 }
8050
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8387 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8051 removearmos(x,y,ffcactivated);
8052 8387 }
8053
8054 1862847 return enemy::animate(index);
8055 1864391 }
8056
8057 1967837 void eOther::draw(BITMAP *dest)
8058 {
8059 1967837 update_enemy_frame();
8060 1967837 enemy::draw(dest);
8061 1967837 }
8062
8063 14141 int32_t eOther::takehit(weapon *w, weapon* realweap)
8064 {
8065 14141 int32_t wpnId = w->id;
8066 14141 int32_t wpnDir = w->dir;
8067
8068
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14116 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
14141 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8069 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8070 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8071 {
8072 shield = false;
8073 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8074
8075 if(get_qr(qr_BRKNSHLDTILES))
8076 o_tile=s_tile;
8077 }
8078
8079 14141 int32_t ret = enemy::takehit(w,realweap);
8080 14141 return ret;
8081 }
8082
8083 void eOther::break_shield()
8084 {
8085 if(!shield)
8086 return;
8087
8088 flags&=~(inv_front | inv_back | inv_left | inv_right);
8089 shield=false;
8090
8091 if(get_qr(qr_BRKNSHLDTILES))
8092 o_tile=s_tile;
8093 }
8094
8095
8096 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8097 {
8098 clk4=0;
8099 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8100
8101 // Spawn type
8102 if(flags & guy_fadeflicker)
8103 {
8104 clk=0;
8105 superman = 1;
8106 fading=fade_flicker;
8107 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8108 dir=down;
8109
8110 if(!canmove(down,(zfix)8,spw_none,false))
8111 clk3=int32_t(13.0/step);
8112 }
8113 else if(flags & guy_fadeinstant)
8114 {
8115 clk=0;
8116 }
8117 SIZEflags = d->SIZEflags;
8118 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8119 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8120 // al_trace("Enemy txsz:%i\n", txsz);
8121 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8122 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8123 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8124 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8125 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8126 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8127 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8128 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8130 {
8131 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8132 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8133 }
8134
8135 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8136 }
8137
8138 bool eScript::animate(int32_t index)
8139 {
8140 if(switch_hooked) return enemy::animate(index);
8141 if(fallclk||drownclk) return enemy::animate(index);
8142 if(fading)
8143 {
8144 if(++clk4 > 60)
8145 {
8146 clk4=0;
8147 superman=0;
8148 fading=0;
8149
8150 if(flags2&cmbflag_armos && z==0 && fakez==0)
8151 removearmos(x,y,ffcactivated);
8152
8153 clk2=0;
8154
8155 if(!canmove(down,(zfix)8,spw_none,false))
8156 {
8157 dir=0;
8158 y = y.getInt() & 0xF0;
8159 }
8160
8161 return Dead(index);
8162 }
8163 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8164 removearmos(x,y,ffcactivated);
8165 }
8166
8167 return enemy::animate(index);
8168 }
8169
8170 void eScript::draw(BITMAP *dest)
8171 {
8172 update_enemy_frame();
8173 enemy::draw(dest);
8174 }
8175
8176 int32_t eScript::takehit(weapon *w, weapon* realweap)
8177 {
8178 int32_t wpnId = w->id;
8179 int32_t wpnDir = w->dir;
8180
8181 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8182 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8183 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8184 {
8185 shield = false;
8186 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8187
8188 if(get_qr(qr_BRKNSHLDTILES))
8189 o_tile=s_tile;
8190 }
8191
8192 int32_t ret = enemy::takehit(w,realweap);
8193 return ret;
8194 }
8195
8196 void eScript::break_shield()
8197 {
8198 if(!shield)
8199 return;
8200
8201 flags&=~(inv_front | inv_back | inv_left | inv_right);
8202 shield=false;
8203
8204 if(get_qr(qr_BRKNSHLDTILES))
8205 o_tile=s_tile;
8206 }
8207
8208
8209 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8210 {
8211 clk4=0;
8212 hyofs = -32768; //No hitbox initially.
8213 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8214
8215 // Spawn type
8216 if(flags & guy_fadeflicker)
8217 {
8218 clk=0;
8219 superman = 1;
8220 fading=fade_flicker;
8221 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8222 dir=down;
8223
8224 if(!canmove(down,(zfix)8,spw_none,false))
8225 clk3=int32_t(13.0/step);
8226 }
8227 else if(flags & guy_fadeinstant)
8228 {
8229 clk=0;
8230 }
8231 SIZEflags = d->SIZEflags;
8232 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8233 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8234 // al_trace("Enemy txsz:%i\n", txsz);
8235 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8236 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8237 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8238 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8239 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8240 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8241 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8242 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8243 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8244 {
8245 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8246 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8247 }
8248
8249 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8250 }
8251
8252 bool eFriendly::animate(int32_t index)
8253 {
8254 if(switch_hooked) return enemy::animate(index);
8255 if(fallclk||drownclk) return enemy::animate(index);
8256 if(fading)
8257 {
8258 if(++clk4 > 60)
8259 {
8260 clk4=0;
8261 superman=0;
8262 fading=0;
8263
8264 if(flags2&cmbflag_armos && z==0 && fakez==0)
8265 removearmos(x,y,ffcactivated);
8266
8267 clk2=0;
8268
8269 if(!canmove(down,(zfix)8,spw_none,false))
8270 {
8271 dir=0;
8272 y = y.getInt() & 0xF0;
8273 }
8274
8275 return Dead(index);
8276 }
8277 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8278 removearmos(x,y,ffcactivated);
8279 }
8280
8281 return enemy::animate(index);
8282 }
8283
8284 void eFriendly::draw(BITMAP *dest)
8285 {
8286 update_enemy_frame();
8287 enemy::draw(dest);
8288 }
8289
8290 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8291 {
8292 int32_t wpnId = w->id;
8293 int32_t wpnDir = w->dir;
8294
8295 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8296 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8297 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8298 {
8299 shield = false;
8300 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8301
8302 if(get_qr(qr_BRKNSHLDTILES))
8303 o_tile=s_tile;
8304 }
8305
8306 int32_t ret = enemy::takehit(w,realweap);
8307 return ret;
8308 }
8309
8310 void eFriendly::break_shield()
8311 {
8312 if(!shield)
8313 return;
8314
8315 flags&=~(inv_front | inv_back | inv_left | inv_right);
8316 shield=false;
8317
8318 if(get_qr(qr_BRKNSHLDTILES))
8319 o_tile=s_tile;
8320 }
8321
8322
8323 779127 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8324 {
8325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779127 times.
779127 if (ffcactive)
8326 {
8327 removearmosffc(ffcactive-1);
8328 return;
8329 }
8330
2/2
✓ Branch 0 taken 778147 times.
✓ Branch 1 taken 980 times.
779127 if(did_armos)
8331 {
8332 778147 return;
8333 }
8334
8335 980 did_armos=true;
8336 980 ax&=0xF0;
8337 980 ay&=0xF0;
8338 980 int32_t cd = (ax>>4)+ay;
8339 980 int32_t f = MAPFLAG(ax,ay);
8340 980 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8341
8342
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 140 times.
980 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8343 {
8344 840 return;
8345 }
8346
8347 140 tmpscr->data[cd] = tmpscr->undercombo;
8348 140 tmpscr->cset[cd] = tmpscr->undercset;
8349 140 tmpscr->sflag[cd] = 0;
8350
8351
3/4
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 118 times.
140 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8352 {
8353 22 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8354 22 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8355 22 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8356 22 sfx(tmpscr->secretsfx);
8357 22 }
8358
8359
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
140 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8360 {
8361
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8362 {
8363 3 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8364 3 sfx(tmpscr->secretsfx);
8365 3 }
8366 3 }
8367
8368 140 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8369 779127 }
8370
8371 void enemy::removearmosffc(int32_t pos)
8372 {
8373 if(did_armos)
8374 {
8375 return;
8376 }
8377
8378 did_armos=true;
8379 ffcdata& ffc = tmpscr->ffcs[pos];
8380 newcombo const& cmb = combobuf[ffc.data];
8381 int32_t f2 = cmb.flag;
8382
8383 if(cmb.type!=cARMOS)
8384 {
8385 return;
8386 }
8387
8388 zc_ffc_set(ffc, tmpscr->undercombo);
8389 ffc.cset = tmpscr->undercset;
8390
8391 if(f2 == mfARMOS_SECRET)
8392 {
8393 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8394 ffc.cset = tmpscr->secretcset[sSTAIRS];
8395 sfx(tmpscr->secretsfx);
8396 }
8397
8398 if(f2 == mfARMOS_ITEM)
8399 {
8400 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8401 {
8402 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8403 sfx(tmpscr->secretsfx);
8404 }
8405 }
8406
8407 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8408 }
8409
8410
8411 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8412 461 {
8413 461 fading=fade_flicker;
8414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8415 461 dir=12;
8416 461 movestatus=1;
8417
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8418 461 clk=0;
8419 461 clk4=0;
8420 461 SIZEflags = d->SIZEflags;
8421
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8422 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8423 // al_trace("Enemy txsz:%i\n", txsz);
8424
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8428
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8429
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8430 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8433 {
8434 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8435 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8436 }
8437
8438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8439 461 }
8440
8441 117025 bool eGhini::animate(int32_t index)
8442 {
8443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8444
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8445
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8446 50 return Dead(index);
8447
8448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8449 {
8450
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8451 {
8452
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8453 54853 misc=2;
8454
8455
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8456 89752 removearmos(x,y,ffcactivated);
8457 89752 }
8458
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8459 {
8460 425 misc=1;
8461 425 clk3=32;
8462 425 fading=0;
8463
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (ffcactivated > 0)
8464 {
8465 guygridffc[ffcactivated-1] = 0;
8466 removearmosffc(ffcactivated-1);
8467 }
8468 else
8469 {
8470 425 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8471 425 removearmos(x,y);
8472 }
8473 425 }
8474 116975 }
8475
8476 116975 clk4++;
8477
8478 116975 return enemy::animate(index);
8479 117025 }
8480
8481 238808 void eGhini::draw(BITMAP *dest)
8482 {
8483 238808 update_enemy_frame();
8484 238808 enemy::draw(dest);
8485 238808 }
8486
8487 2 void eGhini::kickbucket()
8488 {
8489 2 hp=-1000; // don't call death_sfx()
8490 2 }
8491
8492
2/4
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
10392 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8493 5196 {
8494
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 old_y=y;
8495 5196 dir=down;
8496 5196 misc=1;
8497 5196 clk=-15;
8498
8499
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 2551 times.
5196 if(!BSZ)
8500
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 clk*=zc_oldrand()%3+1;
8501
8502 // avoid divide by 0 errors
8503
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc1 == 0)
8504 dmisc1 = 24;
8505
8506
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc2 == 0)
8507 dmisc2 = 3;
8508
8509 //nets+760;
8510 5196 SIZEflags = d->SIZEflags;
8511
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5196 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8512 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8513 // al_trace("Enemy txsz:%i\n", txsz);
8514
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5196 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8518
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8519
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8520 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8521
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
5196 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8523 {
8524 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8525 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8526 }
8527
8528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8529 5196 }
8530
8531 1435270 bool eTektite::animate(int32_t index)
8532 {
8533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435270 times.
1435270 if(switch_hooked) return enemy::animate(index);
8534
4/4
✓ Branch 0 taken 1426328 times.
✓ Branch 1 taken 8942 times.
✓ Branch 2 taken 8942 times.
✓ Branch 3 taken 1423838 times.
1435270 if(fallclk||drownclk) return enemy::animate(index);
8535
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1397171 times.
1423838 if(dying)
8536 26667 return Dead(index);
8537
8538
2/2
✓ Branch 0 taken 1360103 times.
✓ Branch 1 taken 37068 times.
1397171 if(clk==0)
8539 {
8540 37068 removearmos(x,y,ffcactivated);
8541 37068 }
8542
8543
2/2
✓ Branch 0 taken 1055988 times.
✓ Branch 1 taken 341183 times.
1397171 if(get_qr(qr_ENEMIESZAXIS))
8544 {
8545 341183 y=floor_y;
8546 341183 }
8547
8548
9/10
✓ Branch 0 taken 1282576 times.
✓ Branch 1 taken 114595 times.
✓ Branch 2 taken 1269012 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1269012 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1257836 times.
✓ Branch 8 taken 12048 times.
✓ Branch 9 taken 21878 times.
1397171 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8549 {
8550
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421148 times.
✓ Branch 2 taken 344884 times.
✓ Branch 3 taken 493422 times.
1279714 switch(misc)
8551 {
8552 case 0: // normal
8553
2/2
✓ Branch 0 taken 409927 times.
✓ Branch 1 taken 11221 times.
421148 if(!(zc_oldrand()%dmisc1))
8554 {
8555 11221 misc=1;
8556 11221 clk2=32;
8557 11221 }
8558
8559 421148 break;
8560
8561 case 1: // waiting to pounce
8562
2/2
✓ Branch 0 taken 324265 times.
✓ Branch 1 taken 20619 times.
344884 if(--clk2<=0)
8563 {
8564 20619 int32_t r=zc_oldrand();
8565 20619 misc=2;
8566 20619 step=0-(zslongToFix(dstep*100)); // initial speed
8567 20619 clk3=(r&1)+2; // left or right
8568 20619 clk2start=clk2=(r&31)+10; // flight time
8569
8570
2/2
✓ Branch 0 taken 18196 times.
✓ Branch 1 taken 2423 times.
20619 if(y<32) clk2+=2; // make them come down from top of screen
8571
8572
2/2
✓ Branch 0 taken 15702 times.
✓ Branch 1 taken 4917 times.
20619 if(y>112) clk2-=2; // make them go back up
8573
8574 20619 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8575 20619 }
8576
8577 344884 break;
8578
8579 case 2: // in flight
8580 493422 move(step);
8581
8582
2/2
✓ Branch 0 taken 234221 times.
✓ Branch 1 taken 259201 times.
493422 if(step>0) //going down
8583 {
8584
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233589 times.
234221 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8585 {
8586 632 step=0-step;
8587 632 }
8588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8589 {
8590 step=0-step;
8591 }
8592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(ispitfall(x+8,y+16))
8593 {
8594 step=0-step;
8595 }
8596
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233542 times.
233589 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8597 {
8598 47 step=0-step;
8599 47 }
8600
2/2
✓ Branch 0 taken 233531 times.
✓ Branch 1 taken 11 times.
233542 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8601 {
8602 11 step=0-step;
8603 11 }
8604 234221 }
8605
2/2
✓ Branch 0 taken 15154 times.
✓ Branch 1 taken 244047 times.
259201 else if(step<0)
8606 {
8607
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243609 times.
244047 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8608 {
8609 438 step=0-step;
8610 438 }
8611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8612 {
8613 step=0-step;
8614 }
8615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(ispitfall(x+8,y))
8616 {
8617 step=0-step;
8618 }
8619
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243588 times.
243609 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8620 {
8621 21 step=0-step;
8622 21 }
8623
2/2
✓ Branch 0 taken 243569 times.
✓ Branch 1 taken 19 times.
243588 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8624 {
8625 19 step=0-step;
8626 19 }
8627 244047 }
8628
8629
2/2
✓ Branch 0 taken 244152 times.
✓ Branch 1 taken 249270 times.
493422 if(clk3==left)
8630 {
8631
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 243877 times.
244152 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8632 {
8633 275 clk3^=1;
8634 275 }
8635
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 243871 times.
243877 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8636 {
8637 6 clk3^=1;
8638 6 }
8639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243871 times.
243871 else if(ispitfall(x,y+8))
8640 {
8641 clk3^=1;
8642 }
8643
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 243841 times.
243871 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8644 {
8645 30 clk3^=1;
8646 30 }
8647
2/2
✓ Branch 0 taken 243829 times.
✓ Branch 1 taken 12 times.
243841 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8648 {
8649 12 clk3^=1;
8650 12 }
8651 244152 }
8652 else
8653 {
8654
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 248994 times.
249270 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8655 {
8656 276 clk3^=1;
8657 276 }
8658
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 248982 times.
248994 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8659 {
8660 12 clk3^=1;
8661 12 }
8662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248982 times.
248982 else if(ispitfall(x+16,y+8))
8663 {
8664 clk3^=1;
8665 }
8666
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 248977 times.
248982 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8667 {
8668 5 clk3^=1;
8669 5 }
8670
2/2
✓ Branch 0 taken 248965 times.
✓ Branch 1 taken 12 times.
248977 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8671 {
8672 12 clk3^=1;
8673 12 }
8674 }
8675
8676 493422 --c;
8677
8678
4/4
✓ Branch 0 taken 151408 times.
✓ Branch 1 taken 342014 times.
✓ Branch 2 taken 320475 times.
✓ Branch 3 taken 172947 times.
493422 if(c<0 && step<zslongToFix(dstep*100))
8679 {
8680 172947 step+=zslongToFix(dmisc3*100);
8681 172947 }
8682
8683 493422 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8684
8685
2/2
✓ Branch 0 taken 492701 times.
✓ Branch 1 taken 721 times.
493422 if(x<=16-nb) clk3=right;
8686
8687
2/2
✓ Branch 0 taken 492430 times.
✓ Branch 1 taken 992 times.
493422 if(x>=224+nb) clk3=left;
8688
8689 493422 x += (clk3==left) ? -1 : 1;
8690
8691
4/4
✓ Branch 0 taken 29025 times.
✓ Branch 1 taken 464397 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454267 times.
493422 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8692 {
8693
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17274 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39155 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8694 {
8695 185 step=0-step;
8696 185 y--;
8697 185 }
8698
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 12916 times.
18710 else if(zc_oldrand()%dmisc2) //land and wait
8699 {
8700 12916 clk=misc=0;
8701 12916 } //land and jump again
8702 else
8703 {
8704 5794 misc=1;
8705 5794 clk2=0;
8706 }
8707 18895 }
8708
8709 473162 break;
8710 } // switch
8711 1259454 }
8712
8713
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1058478 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1399661 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8714 {
8715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & FLAG_USE_FAKE_Z)
8716 {
8717 int32_t tempy = floor_y;
8718 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8719 floor_y = y;
8720 y=tempy-fakez;
8721 old_y = y;
8722 }
8723 else
8724 {
8725 109977 int32_t tempy = floor_y;
8726
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8727 109977 floor_y = y;
8728 109977 y=tempy-z;
8729 109977 old_y = y;
8730 }
8731 109977 }
8732
8733
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1386097 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1399661 if(stunclk && (clk&31)==1)
8734 10637 clk=0;
8735
8736 1399661 return enemy::animate(index);
8737 1426328 }
8738
8739 803206 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8740 {
8741
5/6
✓ Branch 0 taken 625928 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 625928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600737 times.
✓ Branch 5 taken 25191 times.
803206 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8742 25191 return;
8743
8744 778015 int32_t tempy=yofs;
8745 778015 int32_t fdiv = frate/4;
8746
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8747
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8748 778015 efrate:((clk>=(frate>>1))?1:0);
8749 778015 flip = 0;
8750 778015 shadowtile = wpnsbuf[spr_shadow].tile;
8751
8752
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 if(get_qr(qr_NEWENEMYTILES))
8753 {
8754
2/2
✓ Branch 0 taken 575932 times.
✓ Branch 1 taken 202083 times.
778015 if(misc==0)
8755 {
8756 202083 shadowtile+=f2;
8757 202083 }
8758
2/2
✓ Branch 0 taken 254903 times.
✓ Branch 1 taken 321029 times.
575932 else if(misc!=1)
8759 321029 shadowtile+=2;
8760 778015 }
8761 else
8762 {
8763 if(misc==0)
8764 {
8765 shadowtile += f2 ? 1 : 0;
8766 }
8767 else if(misc!=1)
8768 {
8769 ++shadowtile;
8770 }
8771 }
8772
8773 778015 yofs+=8;
8774
8775
4/4
✓ Branch 0 taken 600737 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 339908 times.
✓ Branch 3 taken 260829 times.
778015 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8776 {
8777
6/6
✓ Branch 0 taken 134073 times.
✓ Branch 1 taken 126756 times.
✓ Branch 2 taken 243385 times.
✓ Branch 3 taken 17444 times.
✓ Branch 4 taken 123475 times.
✓ Branch 5 taken 119910 times.
260829 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8778 260829 }
8779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 778015 times.
778015 if(!shadow_overpit(this))
8780 778015 enemy::drawshadow(dest,translucent);
8781 778015 yofs=tempy;
8782 803206 }
8783
8784 2045360 void eTektite::draw(BITMAP *dest)
8785 {
8786 2045360 update_enemy_frame();
8787 2045360 enemy::draw(dest);
8788 2045360 }
8789
8790 730 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8791 730 {
8792
2/4
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
730 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8793 730 superman=1;
8794 730 dir=8;
8795 730 hxofs=1000;
8796 730 mainguy=false;
8797 730 count_enemy=false;
8798
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
730 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8799 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8800 // al_trace("Enemy txsz:%i\n", txsz);
8801
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
730 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
8802
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
8803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
8804
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
8805
1/2
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
730 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
8806
1/2
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
730 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
8807 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8808
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
730 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
8809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
730 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8810 {
8811 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
8812 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8813 }
8814
8815
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
730 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
8816 730 }
8817
8818 279897 bool eItemFairy::animate(int32_t index)
8819 {
8820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(switch_hooked) return enemy::animate(index);
8821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(dying)
8822 return Dead(index);
8823
8824 //if(clk>32)
8825 279897 misc=1;
8826 279897 bool w=watch;
8827 279897 watch=false;
8828 279897 variable_walk_8(misc?3:0,0,8,spw_floater);
8829 279897 watch=w;
8830
8831
2/2
✓ Branch 0 taken 1514 times.
✓ Branch 1 taken 278383 times.
279897 if(clk==0)
8832 {
8833 1514 removearmos(x,y,ffcactivated);
8834 1514 }
8835
8836 279897 return enemy::animate(index);
8837 279897 }
8838
8839 562150 void eItemFairy::draw(BITMAP *dest)
8840 {
8841 //these are here to bypass compiler warnings about unused arguments
8842 562150 dest=dest;
8843 562150 }
8844
8845 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8846 1825 {
8847 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8848
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8849 1825 dir=8;
8850 1825 movestatus=1;
8851 1825 clk=0;
8852
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8853 //nets+720;
8854 1825 SIZEflags = d->SIZEflags;
8855
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1825 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8856 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8857 // al_trace("Enemy txsz:%i\n", txsz);
8858
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1825 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8860
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8861
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8862
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8863
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8864 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8865
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
1825 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8867 {
8868 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8869 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8870 }
8871
8872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8873 1825 }
8874
8875 520615 bool ePeahat::animate(int32_t index)
8876 {
8877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8878
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8879
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8880 {
8881 78 return false;
8882 }
8883
8884
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8885 1030 return Dead(index);
8886
8887
2/2
✓ Branch 0 taken 516424 times.
✓ Branch 1 taken 3083 times.
519507 if(clk==0)
8888 {
8889 3083 removearmos(x,y,ffcactivated);
8890 3083 }
8891
8892
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8893 263053 misc=1;
8894
8895
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8896
2/2
✓ Branch 0 taken 345614 times.
✓ Branch 1 taken 171491 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8897
8898
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8899 {
8900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8901 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8902 100018 }
8903
8904
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8905 1634 superman=0;
8906 else
8907
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8908 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8909
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8910 {
8911
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8912 264937 }
8913 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8914 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8915
8916
8917
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8918
8919 519507 return enemy::animate(index);
8920 520615 }
8921
8922 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8923 {
8924 334520 int32_t tempy=yofs;
8925 334520 flip = 0;
8926 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8927
8928
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8929 {
8930 246431 yofs+=8;
8931 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8932 246431 }
8933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8934 334520 enemy::drawshadow(dest,translucent);
8935 334520 yofs=tempy;
8936 334520 }
8937
8938 1144330 void ePeahat::draw(BITMAP *dest)
8939 {
8940 1144330 update_enemy_frame();
8941 1144330 enemy::draw(dest);
8942 1144330 }
8943
8944 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8945 {
8946 4136 int32_t wpnId = w->id;
8947 4136 int32_t enemyHitWeapon = w->parentitem;
8948
8949
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8950 return 0;
8951
8952
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8953 // fire boomerang, for nailing peahats
8954
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8955 3343 return 0;
8956
8957 // Time for a kludge...
8958 793 int32_t s = superman;
8959 793 superman = 0;
8960 793 int32_t ret = enemy::takehit(w,realweap);
8961 793 superman = s;
8962
8963 // Anyway...
8964
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8965 {
8966 192 clk2=0;
8967 192 movestatus=0;
8968 192 misc=0;
8969 192 clk=0;
8970 192 step=0;
8971 192 }
8972
8973 793 return ret;
8974 4136 }
8975
8976 // auomatically kill off enemy (for rooms with ringleaders)
8977 void ePeahat::kickbucket()
8978 {
8979 hp=-1000; // don't call death_sfx()
8980 }
8981
8982 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8983 3942 {
8984 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8985
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8986 {
8987 2147 misc=-1; //Line of Sight leevers
8988 2147 clk-=16;
8989 2147 }
8990 3942 clk3 = 0;
8991 //nets+1460;
8992 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8993 3942 submerged = false;
8994 3942 SIZEflags = d->SIZEflags;
8995
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3942 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8996 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8997 // al_trace("Enemy txsz:%i\n", txsz);
8998
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3942 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9002
1/2
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
3942 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9003
1/2
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
3942 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9004 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9005
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3942 times.
3942 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9007 {
9008 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9009 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9010 }
9011
9012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3942 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9013 3942 }
9014
9015 923 bool eLeever::isSubmerged() const
9016 {
9017 923 Z_scripterrlog("misc is: %d\n", misc);
9018 923 return misc <= 0;
9019
9020 }
9021
9022 1018478 bool eLeever::animate(int32_t index)
9023 {
9024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
9025
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
9026 {
9027 355 return enemy::animate(index);
9028 }
9029
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
9030 31552 return Dead(index);
9031
9032
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
9033 {
9034 44970 removearmos(x,y,ffcactivated);
9035 44970 }
9036
9037
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
9038 {
9039 // switch(d->misc1)
9040
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
9041 {
9042 case 0: //line of sight
9043 case 2:
9044
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
9045 {
9046 case -1: //submerged
9047 {
9048
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
9049
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
9050 {
9051 10261 break;
9052 }
9053
9054 114198 int32_t active=0;
9055
9056
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
9057 {
9058
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
9059 {
9060 225696 ++active;
9061 225696 }
9062 783342 }
9063
9064
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
9065 {
9066 1871 misc=0; //activate this one
9067 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
9068 1871 }
9069 }
9070 114198 break;
9071
9072 case 0:
9073 {
9074
9075
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9076 {
9077 misc=1;
9078 clk2=0;
9079 }
9080
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
9081 {
9082 57 misc = -1;
9083 57 break;
9084 }
9085 49052 int32_t s=0;
9086
9087
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
9088 {
9089
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
9090 {
9091 7882 ++s;
9092 7882 }
9093 273250 }
9094
9095
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
9096 {
9097 7882 break;
9098 }
9099
9100 41170 int32_t d2=zc_oldrand()&1;
9101
9102
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
9103 {
9104 26661 d2+=2;
9105 26661 }
9106
9107
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 662 times.
✓ Branch 3 taken 39060 times.
41170 if(canplace(d2) || canplace(d2^1))
9108 {
9109 2110 misc=1;
9110 2110 clk2=0;
9111 2110 clk=0;
9112 2110 }
9113 }
9114 41170 break;
9115
9116 case 1:
9117
9118
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9119
9120 35464 break;
9121
9122 case 2:
9123
9124
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9125
9126 15780 break;
9127
9128 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9129 case 3:
9130
9131
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9132
9133
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9134
9135
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9136 94963 else move(zslongToFix(dstep*100));
9137
9138 95468 break;
9139
9140 case 4:
9141
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9142
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9143 {
9144 468 misc=5;
9145 468 clk=8;
9146 468 }
9147
9148 4365 break;
9149
9150 case 5:
9151
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9152
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9153
9154 6907 break;
9155 } // switch(misc)
9156
9157 337868 break;
9158
9159 default: //random
9160 // step=d->misc3/100.0;
9161
9162 473814 step=zslongToFix(dmisc3*100);
9163
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9164 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9165 {
9166 if (clk2 < 48) clk2+=2;
9167 if (clk2 >= 300) clk2-=2;
9168 }
9169
9170
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9171
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9172
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9173 {
9174 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9175 {
9176 fix_coords();
9177 }*/
9178 289541 misc=3;
9179 289541 step = zslongToFix(dstep*100);
9180 289541 }
9181
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9182
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9183
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9184 {
9185 40151 misc=0;
9186 40151 step=0;
9187 40151 }
9188 274 else clk2=0;
9189
9190
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9191
9192 // variable_walk(d->rate, d->homing, 0);
9193 473814 variable_walk(rate, homing, 0);
9194 473814 } // switch(dmisc1)
9195 811682 }
9196
9197 986571 hxofs=(misc>=2)?0:1000;
9198 986571 return enemy::animate(index);
9199 1018478 }
9200
9201 80892 bool eLeever::canplace(int32_t d2)
9202 {
9203 80892 int32_t nx=HeroX();
9204 80892 int32_t ny=HeroY();
9205
9206
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny&=0xF0;
9207 52400 else nx&=0xF0;
9208
9209
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9210 {
9211 // case up: ny-=((d->misc1==0)?32:48); break;
9212 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9213 // case left: nx-=((d->misc1==0)?32:48); break;
9214 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9215 case up:
9216
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9217 14174 break;
9218
9219 case down:
9220
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9221
9222
4/4
✓ Branch 0 taken 10086 times.
✓ Branch 1 taken 4232 times.
✓ Branch 2 taken 10075 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9223
9224 14318 break;
9225
9226 case left:
9227
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9228 26181 break;
9229
9230 case right:
9231
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9232
9233
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9234
9235 26219 break;
9236 }
9237
9238
4/4
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 60464 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11427 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9239 69465 return false;
9240
9241
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 10563 times.
11427 if(d2>=left)
9242
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9243 9317 return false;
9244
9245 2110 x=nx;
9246 2110 y=ny;
9247 2110 dir=d2^1;
9248 2110 return true;
9249 80892 }
9250
9251 1024382 void eLeever::draw(BITMAP *dest)
9252 {
9253 // cs=d->cset;
9254 1024382 cs=dcset;
9255 1024382 update_enemy_frame();
9256
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9257 {
9258
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9259 {
9260 case -1:
9261 case 0:
9262 386939 return;
9263 }
9264 637088 }
9265
9266 637443 enemy::draw(dest);
9267 1024382 }
9268
9269 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9270 998 {
9271 //zprint2("eWallM::eWallM\n");
9272 998 hashero=false;
9273 //nets+1000;
9274 998 SIZEflags = d->SIZEflags;
9275
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
998 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9276 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9277 // al_trace("Enemy txsz:%i\n", txsz);
9278
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
998 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9279
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9281
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9282
1/2
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
998 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9283
1/2
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
998 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9284 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9285
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
998 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9287 {
9288 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9289 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9290 }
9291
9292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9293 998 }
9294
9295 504762 bool eWallM::animate(int32_t index)
9296 {
9297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9298
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9299 {
9300 return enemy::animate(index);
9301 }
9302
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9303 9856 return Dead(index);
9304
9305
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9306 {
9307 30976 removearmos(x,y,ffcactivated);
9308 30976 }
9309
9310 494906 hxofs=1000;
9311
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9312 {
9313 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
9314 //zprint2("frame is: %d\n",frame);
9315 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
9316
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9317 {
9318 //zprint2("getting wall\n");
9319 211789 int32_t wall=hero_on_wall();
9320 //zprint2("Wallmaster wall is %d\n",wall);
9321 211789 int32_t wallm_cnt=0;
9322
9323
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9324
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9325 {
9326 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9327
9328
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9329 {
9330 13366 ++wallm_cnt;
9331 13366 }
9332 1013091 }
9333
9334
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9335 {
9336 841 --wall;
9337 841 misc=1; //emerging from the wall?
9338 //zprint2("Wallmaster is emerging\n");
9339 841 clk2=0;
9340 841 clk3=wall^1;
9341 841 wallm_load_clk=frame;
9342
9343
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9344 {
9345
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9346 91 dir=right;
9347 else
9348 423 dir=left;
9349 514 }
9350 else
9351 {
9352
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9353 66 dir=down;
9354 else
9355 261 dir=up;
9356 }
9357
9358
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9359 {
9360 case up:
9361 231 y=0;
9362 231 break;
9363
9364 case down:
9365 283 y=160;
9366 283 break;
9367
9368 case left:
9369 223 x=0;
9370 223 break;
9371
9372 case right:
9373 104 x=240;
9374 104 break;
9375 }
9376
9377 //zprint2("Wallmaster (p1) x is %d\n",x);
9378 //zprint2("Wallmaster (p1) y is %d\n",y);
9379
9380
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9381 {
9382 case up:
9383 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9384 261 flip=wall&1;
9385 261 break;
9386
9387 case down:
9388 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9389 66 flip=((wall&1)^1)+2;
9390 66 break;
9391
9392 case left:
9393 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9394 423 flip=(wall==up?2:0)+1;
9395 423 break;
9396
9397 case right:
9398 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9399 91 flip=(wall==up?2:0);
9400 91 break;
9401 }
9402
9403 //zprint2("Wallmaster (p2) x is %d\n",x);
9404 //zprint2("Wallmaster (p2) y is %d\n",y);
9405 841 }
9406 211789 }
9407 377174 }
9408 else
9409 117732 wallm_crawl();
9410
9411 494906 return enemy::animate(index);
9412 504762 }
9413
9414 117732 void eWallM::wallm_crawl()
9415 {
9416 117732 bool w=watch;
9417 117732 hxofs=0;
9418
9419
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9420 {
9421 810 return;
9422 }
9423
9424 // if(dying || watch || (!hashero && stunclk))
9425
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9426 {
9427 14546 return;
9428 }
9429
9430 102376 watch=false;
9431 102376 ++clk2;
9432 // Misc1: slightly different movement
9433 //zprint2("wallmaster crawl\n");
9434 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
9435 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9436
9437 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9438 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
9439 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
9440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9441 //zprint2("wallmaster crawl misc is: %d\n", misc);
9442
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9443 {
9444 4491 --clk2;
9445 4491 }
9446
9447
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9448 {
9449 case 1:
9450 case 2:
9451 52852 zc_swap(dir,clk3);
9452 52852 move(step);
9453 52852 zc_swap(dir,clk3);
9454 52852 break;
9455
9456 case 3:
9457 case 4:
9458 case 5:
9459
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9460 {
9461 4491 watch=w;
9462 4491 return;
9463 }
9464
9465 34905 move(step);
9466 34905 break;
9467
9468 case 6:
9469 case 7:
9470 9984 zc_swap(dir,clk3);
9471 9984 dir^=1;
9472 9984 move(step);
9473 9984 dir^=1;
9474 9984 zc_swap(dir,clk3);
9475 9984 break;
9476
9477 default:
9478 144 misc=0;
9479 144 break;
9480 }
9481
9482 97885 watch=w;
9483 117732 }
9484
9485 9 void eWallM::grabhero()
9486 {
9487 9 hashero=true;
9488 9 superman=1;
9489 9 }
9490
9491 507147 void eWallM::draw(BITMAP *dest)
9492 {
9493 507147 dummy_bool[1]=hashero;
9494 507147 update_enemy_frame();
9495
9496
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9497 {
9498 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9499 129181 }
9500
9501 // enemy::draw(dest);
9502 // tile = clk&8 ? 128:129;
9503 507147 }
9504
9505 bool eWallM::isSubmerged() const
9506 {
9507 return ( !misc );
9508 }
9509
9510 1600 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9511 1600 {
9512
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 ox=x; //original x
9513
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 oy=y; //original y
9514
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 126 times.
1600 if(get_qr(qr_TRAPPOSFIX))
9515 {
9516
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9517 126 }
9518
9519 1600 mainguy=false;
9520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9521 //nets+420;
9522 1600 dummy_int[1]=0;
9523 1600 SIZEflags = d->SIZEflags;
9524
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1600 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9525 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9526 // al_trace("Enemy txsz:%i\n", txsz);
9527
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1600 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9531
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9532
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9533 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9536 {
9537 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9538 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9539 }
9540
9541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9542 1600 }
9543
9544 1036935 bool eTrap::animate(int32_t index)
9545 {
9546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1036935 times.
1036935 if(switch_hooked) return enemy::animate(index);
9547
2/4
✓ Branch 0 taken 1036935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1036935 times.
1036935 if(fallclk||drownclk) return enemy::animate(index);
9548
2/2
✓ Branch 0 taken 1015341 times.
✓ Branch 1 taken 21594 times.
1036935 if(clk<0)
9549 21594 return enemy::animate(index);
9550
9551
2/2
✓ Branch 0 taken 951124 times.
✓ Branch 1 taken 64217 times.
1015341 if(clk==0)
9552 {
9553 64217 removearmos(x,y,ffcactivated);
9554 64217 }
9555
9556
2/2
✓ Branch 0 taken 317997 times.
✓ Branch 1 taken 697344 times.
1015341 if(misc==0) // waiting
9557 {
9558 697344 ox = x;
9559 697344 oy = y;
9560 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9561 697344 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9562
9563
4/4
✓ Branch 0 taken 240663 times.
✓ Branch 1 taken 456681 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 107487 times.
697344 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9564 {
9565 107487 dir=down;
9566 107487 }
9567
4/4
✓ Branch 0 taken 391518 times.
✓ Branch 1 taken 198339 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 258342 times.
589857 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9568 {
9569 258342 dir=right;
9570 258342 }
9571
4/4
✓ Branch 0 taken 210645 times.
✓ Branch 1 taken 120870 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 77469 times.
331515 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9572 {
9573 77469 dir=up;
9574 77469 }
9575 else
9576 {
9577 254046 dir=left;
9578 }
9579
9580 697344 int32_t d2=lined_up(15,true);
9581
9582
4/4
✓ Branch 0 taken 267045 times.
✓ Branch 1 taken 430299 times.
✓ Branch 2 taken 1111152 times.
✓ Branch 3 taken 413808 times.
1091329 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9583
2/2
✓ Branch 0 taken 232556 times.
✓ Branch 1 taken 190596 times.
413808 ((d2>down) && (dmisc1==2)) ||
9584
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 60611 times.
190596 ((d2>right) && (!dmisc1)) ||
9585
2/2
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
247680 ((d2<l_up) && (dmisc1==4)) ||
9586
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 247680 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
146305 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9587
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
247680 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9588 {
9589 2525663 d2=-1;
9590 2525663 }
9591
9592
4/4
✓ Branch 0 taken 20700 times.
✓ Branch 1 taken 428964 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2107 times.
449664 if(d2!=-1 && trapmove(d2))
9593 {
9594 2107 dir=d2;
9595 2107 misc=1;
9596 2107 clk2=(dir==down)?3:0;
9597 2107 }
9598 449664 }
9599
9600
2/2
✓ Branch 0 taken 678404 times.
✓ Branch 1 taken 89257 times.
767661 if(misc==1) // charging
9601 {
9602 89257 clk2=(clk2+1)&3;
9603 89257 step=(clk2==3)?1:2;
9604
9605
4/4
✓ Branch 0 taken 88461 times.
✓ Branch 1 taken 796 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87356 times.
89257 if(!trapmove(dir) || clip())
9606 {
9607 1901 misc=2;
9608
9609
1/2
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
1901 if(dir<l_up)
9610 {
9611 1901 dir=dir^1;
9612 1901 }
9613 else
9614 {
9615 dir=dir^3;
9616 }
9617 1901 }
9618 else
9619 {
9620 87356 sprite::move(step);
9621 }
9622 89257 }
9623
9624
2/2
✓ Branch 0 taken 534913 times.
✓ Branch 1 taken 232748 times.
767661 if(misc==2) // retreating
9625 {
9626 232748 step=(++clk2&1)?1:0;
9627
9628
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80505 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84103 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
232748 switch(dir)
9629 {
9630 case up:
9631
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9632 38739 else sprite::move(step);
9633
9634 38739 break;
9635
9636 case left:
9637
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 80117 times.
80505 if(int32_t(x)<=ox) goto trap_rest;
9638 80117 else sprite::move(step);
9639
9640 80117 break;
9641
9642 case down:
9643
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9644 28905 else sprite::move(step);
9645
9646 28905 break;
9647
9648 case right:
9649
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 83672 times.
84103 if(int32_t(x)>=ox) goto trap_rest;
9650 83672 else sprite::move(step);
9651
9652 83672 break;
9653
9654 case l_up:
9655 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9656 else sprite::move(step);
9657
9658 break;
9659
9660 case r_up:
9661 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9662 else sprite::move(step);
9663
9664 break;
9665
9666 case l_down:
9667 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9668 else sprite::move(step);
9669
9670 break;
9671
9672 case r_down:
9673 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9674 else sprite::move(step);
9675
9676 break;
9677 trap_rest:
9678 {
9679 1315 x=ox;
9680 1315 y=oy;
9681 1315 misc=0;
9682 }
9683 1315 }
9684 232748 }
9685
9686 767661 return enemy::animate(index);
9687 789255 }
9688
9689 109957 bool eTrap::trapmove(int32_t ndir)
9690 {
9691
2/2
✓ Branch 0 taken 80193 times.
✓ Branch 1 taken 29764 times.
109957 if(get_qr(qr_MEANTRAPS))
9692 {
9693
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 78853 times.
80193 if(tmpscr->flags2&fFLOATTRAPS)
9694 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9695
9696 78853 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9697 }
9698
9699
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9700 4730 return false;
9701
9702
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9703 return false;
9704
9705
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9706 return false;
9707
9708
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9709 return false;
9710
9711
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9712 4722 return false;
9713
9714
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9715 713 return false;
9716
9717
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9718 return false;
9719
9720
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9721 return false;
9722
9723
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9724 return false;
9725
9726
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9727 return false;
9728
9729 19599 return true;
9730 109957 }
9731
9732 88461 bool eTrap::clip()
9733 {
9734
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45439 times.
88461 if(get_qr(qr_MEANPLACEDTRAPS))
9735 {
9736
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 15895 times.
✓ Branch 4 taken 15096 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45439 switch(dir)
9737 {
9738 case up:
9739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9740
9741 5792 break;
9742
9743 case down:
9744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=160) return true;
9745
9746 8656 break;
9747
9748 case left:
9749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15895 times.
15895 if(x<=0) return true;
9750
9751 15895 break;
9752
9753 case right:
9754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15096 times.
15096 if(x>=240) return true;
9755
9756 15096 break;
9757
9758 case l_up:
9759 if(y<=0||x<=0) return true;
9760
9761 break;
9762
9763 case l_down:
9764 if(y>=160||x<=0) return true;
9765
9766 break;
9767
9768 case r_up:
9769 if(y<=0||x>=240) return true;
9770
9771 break;
9772
9773 case r_down:
9774 if(y>=160||x>=240) return true;
9775
9776 break;
9777 }
9778
9779 45439 return false;
9780 }
9781 else
9782 {
9783
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9784 {
9785 case up:
9786
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9787
9788 4695 break;
9789
9790 case down:
9791
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9792
9793 5253 break;
9794
9795 case left:
9796
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9797
9798 16376 break;
9799
9800 case right:
9801
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9802
9803 15593 break;
9804
9805 case l_up:
9806 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9807
9808 break;
9809
9810 case l_down:
9811 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9812
9813 break;
9814
9815 case r_up:
9816 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9817
9818 break;
9819
9820 case r_down:
9821 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9822
9823 break;
9824 }
9825
9826 41917 return false;
9827 }
9828 88461 }
9829
9830 1043991 void eTrap::draw(BITMAP *dest)
9831 {
9832 1043991 update_enemy_frame();
9833 1043991 enemy::draw(dest);
9834 1043991 }
9835
9836 5705 int32_t eTrap::takehit(weapon*,weapon*)
9837 {
9838 5705 return 0;
9839 }
9840
9841 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9842 832 {
9843 832 lasthit=-1;
9844 832 lasthitclk=0;
9845 832 mainguy=false;
9846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9847
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9848
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9849 {
9850
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9851 399 }
9852 else
9853 {
9854
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9855 }
9856
9857
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9858 {
9859
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9860 72 }
9861
9862 //nets+((id==eTRAP_LR)?540:520);
9863 832 dummy_int[1]=0;
9864 832 SIZEflags = d->SIZEflags;
9865
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9866 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9867 // al_trace("Enemy txsz:%i\n", txsz);
9868
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9869
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9870
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9871
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9872
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9873
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9874 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9877 {
9878 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9879 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9880 }
9881
9882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9883 832 }
9884
9885 346559 bool eTrap2::animate(int32_t index)
9886 {
9887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9888
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9889
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9890 11026 return enemy::animate(index);
9891
9892
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9893 {
9894 21385 removearmos(x,y,ffcactivated);
9895 21385 }
9896
9897
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9898 {
9899
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9900 {
9901 11074 --lasthitclk;
9902 11074 }
9903 else
9904 {
9905 113252 lasthit=-1;
9906 }
9907
9908 124326 bool hitenemy=false;
9909
9910
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9911 {
9912
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9913 {
9914
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9915 {
9916 3669 lasthit=j;
9917 3669 lasthitclk=10;
9918 3669 hitenemy=true;
9919 3669 guys.spr(j)->lasthit=index;
9920 3669 guys.spr(j)->lasthitclk=10;
9921 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9922 3669 }
9923 730351 }
9924 864860 }
9925
9926
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9927 {
9928
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9929 {
9930 3155 lasthit=-1;
9931 3155 lasthitclk=0;
9932 3155 }
9933
9934
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9935 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9936
9937 5986 dir=dir^1;
9938 5986 }
9939
9940 124326 sprite::move(step);
9941 124326 }
9942 else
9943 {
9944
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9945 {
9946
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9947 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9948
9949 6919 dir=dir^1;
9950 6919 }
9951
9952 211207 sprite::move(step);
9953 }
9954
9955 335533 return enemy::animate(index);
9956 346559 }
9957
9958 341519 bool eTrap2::trapmove(int32_t ndir)
9959 {
9960
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(tmpscr->flags2&fFLOATTRAPS)
9961 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9962
9963 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9964 341519 }
9965
9966 328290 bool eTrap2::clip()
9967 {
9968
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9969 {
9970 case up:
9971
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9972
9973 88320 break;
9974
9975 case down:
9976
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=160) return true;
9977
9978 89029 break;
9979
9980 case left:
9981
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9982
9983 75153 break;
9984
9985 case right:
9986
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=240) return true;
9987
9988 75788 break;
9989 }
9990
9991 328290 return false;
9992 328290 }
9993
9994 350933 void eTrap2::draw(BITMAP *dest)
9995 {
9996 350933 update_enemy_frame();
9997 350933 enemy::draw(dest);
9998 350933 }
9999
10000 3169 int32_t eTrap2::takehit(weapon*,weapon*)
10001 {
10002 3169 return 0;
10003 }
10004
10005 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10006 354 {
10007 //do not show "enemy appering" anim -DD
10008 354 clk=0;
10009 354 mainguy=false;
10010 354 clk2=-14;
10011 //Enemy Editor Size Tab
10012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10013 354 else hxofs = -2;
10014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10015 354 else hyofs = -2;
10016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10017 354 else hit_width = 20;
10018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10019 354 else hit_height=20;
10020
10021
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10022
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10024
1/4
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10026 {
10027 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10028 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10029 }
10030
10031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10032 //nets+1640;
10033 354 }
10034
10035 121997 bool eRock::animate(int32_t index)
10036 {
10037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
10038
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
10039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
10040 return Dead(index);
10041
10042
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
10043 {
10044 8376 removearmos(x,y,ffcactivated);
10045 8376 }
10046
10047
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
10048 {
10049 697 x=zc_oldrand()&0xF0;
10050 697 y=0;
10051 697 clk3=0;
10052 697 clk2=zc_oldrand()&15;
10053 697 }
10054
10055
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
10056 {
10057
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
10058 {
10059 3430 dir=zc_oldrand()&1;
10060
10061
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
10062
10063
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
10064 3430 }
10065
10066
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
10067 {
10068 95993 x += dir ? 1 : -1; //right, left
10069 95993 dummy_int[1]=dir;
10070
10071
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
10072 {
10073 6852 y-=2; //up
10074 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10075 6852 }
10076
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
10077 {
10078 10208 y--; //up
10079 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10080 10208 }
10081
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
10082 {
10083 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
10084 10135 }
10085
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
10086 {
10087 10058 y++; //down
10088 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10089 10058 }
10090 else
10091 {
10092 58740 y+=2; //down
10093 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10094 }
10095
10096 95993 ++clk3;
10097 95993 }
10098
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<176)
10099 2761 clk3=0; // next bounce
10100 else
10101 423 clk2 = -(zc_oldrand()&63); // back to top
10102 99177 }
10103
10104 121997 return enemy::animate(index);
10105 121997 }
10106
10107 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
10108 {
10109
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
10110 {
10111 44250 int32_t tempy=yofs;
10112 44250 flip = 0;
10113 44250 int32_t fdiv = frate/4;
10114
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10115
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
10116 44250 efrate:((clk>=(frate>>1))?1:0);
10117 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10118
10119 44250 yofs+=8;
10120
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
10122 44250 enemy::drawshadow(dest, translucent);
10123 44250 yofs=tempy;
10124 44250 }
10125 51441 }
10126
10127 122078 void eRock::draw(BITMAP *dest)
10128 {
10129
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
10130 {
10131 105043 int32_t tempdir=dir;
10132 105043 dir=dummy_int[2];
10133 105043 update_enemy_frame();
10134 105043 enemy::draw(dest);
10135 105043 dir=tempdir;
10136 105043 }
10137 122078 }
10138
10139 1014 int32_t eRock::takehit(weapon*,weapon*)
10140 {
10141 1014 return 0;
10142 }
10143
10144 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10145 30 {
10146 30 clk=0;
10147 30 mainguy=false;
10148 30 clk2=-14;
10149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10150 30 else hxofs= -10;
10151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10152 30 else hyofs=-10;
10153
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10154 30 else hit_width=36;
10155
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10156 30 else hit_height=36;
10157
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10158 30 else hzsz=16; //can't be jumped
10159
10160
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10161
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10163
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10165 {
10166 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10167 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10168 }
10169
10170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10171 //nets+1680;
10172 30 }
10173
10174 4440 bool eBoulder::animate(int32_t index)
10175 {
10176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
10177
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
10178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
10179 return Dead(index);
10180
10181
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
10182 {
10183 290 removearmos(x,y,ffcactivated);
10184 290 }
10185
10186 zfix *vert;
10187
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10188
10189
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10190 {
10191 32 x=zc_oldrand()&0xF0;
10192 32 y=-32;
10193 32 clk3=0;
10194 32 clk2=zc_oldrand()&15;
10195 32 }
10196
10197
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10198 {
10199
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10200 {
10201 131 dir=zc_oldrand()&1;
10202
10203
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10204
10205
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10206 131 }
10207
10208
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10209 {
10210 3487 x += dir ? 1 : -1; //right, left
10211 3487 dummy_int[1]=dir;
10212
10213
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10214 {
10215 261 y-=2; //up
10216 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10217 261 }
10218
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10219 {
10220 382 y--; //up
10221 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10222 382 }
10223
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10224 {
10225 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10226 376 }
10227
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10228 {
10229 367 y++; //down
10230 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10231 367 }
10232 else
10233 {
10234 2101 y+=2; //down
10235 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10236 }
10237
10238 3487 ++clk3;
10239 3487 }
10240
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10241 101 clk3=0; // next bounce
10242 else
10243 10 clk2 = -(zc_oldrand()&63); // back to top
10244 3598 }
10245
10246 4440 return enemy::animate(index);
10247 4440 }
10248
10249 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10250 {
10251
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10252 {
10253 3868 int32_t tempy=yofs;
10254 3868 flip = 0;
10255 3868 int32_t f2=((clk<<2)/frate)<<1;
10256 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10257
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10258
10259 3868 yofs+=8;
10260 3868 xofs-=8;
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10262 3868 enemy::drawshadow(dest, translucent);
10263 3868 xofs+=16;
10264 3868 ++shadowtile;
10265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10266 3868 enemy::drawshadow(dest, translucent);
10267 3868 yofs+=16;
10268 3868 shadowtile+=20;
10269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10270 3868 enemy::drawshadow(dest, translucent);
10271 3868 xofs-=16;
10272 3868 --shadowtile;
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10274 3868 enemy::drawshadow(dest, translucent);
10275 3868 xofs+=8;
10276 3868 yofs=tempy;
10277 3868 }
10278 4440 }
10279
10280 4440 void eBoulder::draw(BITMAP *dest)
10281 {
10282
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10283 {
10284 3868 int32_t tempdir=dir;
10285 3868 dir=dummy_int[2];
10286 3868 update_enemy_frame();
10287 3868 dir=tempdir;
10288 3868 xofs-=8;
10289 3868 yofs-=8;
10290 3868 drawblock(dest,15);
10291 3868 xofs+=8;
10292 3868 yofs+=8;
10293 // enemy::draw(dest);
10294 3868 }
10295 4440 }
10296
10297 int32_t eBoulder::takehit(weapon*,weapon*)
10298 {
10299 return 0;
10300 }
10301
10302 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10303
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10304 4429 {
10305 /* fixing
10306 hp=1;
10307 */
10308 4429 mainguy=false;
10309
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10310 4429 hclk=clk; // the "no fire" range
10311 4429 clk=0;
10312 4429 clk3=96;
10313 4429 timer=0;
10314
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10315 {
10316 4415 superman=1;
10317 4415 hxofs=1000;
10318 4415 }
10319 4429 SIZEflags = d->SIZEflags;
10320
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4429 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10321 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10322 // al_trace("Enemy txsz:%i\n", txsz);
10323
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4429 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10324
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10327
1/2
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
4429 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10328
1/2
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
4429 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10329 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10330
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4429 times.
4429 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10332 {
10333 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10334 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10335 }
10336
10337
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4429 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10338 4429 }
10339
10340 2504746 bool eProjectile::animate(int32_t index)
10341 {
10342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10343
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10344
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10345 {
10346 12326 removearmos(x,y,ffcactivated);
10347 12326 }
10348
10349 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10350 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10351
10352
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10353 {
10354 403631 dir=down;
10355 403631 }
10356
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10357 {
10358 916920 dir=right;
10359 916920 }
10360
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10361 {
10362 358900 dir=up;
10363 358900 }
10364 else
10365 {
10366 825295 dir=left;
10367 }
10368
10369
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10370 {
10371
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10372 {
10373
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10374 {
10375 563 unsigned r=zc_oldrand();
10376
10377
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10378 {
10379 6 timer=zc_oldrand()%50+50;
10380 6 }
10381 563 }
10382
10383
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10384 {
10385
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10386 {
10387 119 FireBreath(false);
10388 119 }
10389
10390
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10391 {
10392 6 clk3=0;
10393 6 }
10394 489 }
10395 1046 }
10396
10397 else // Not breath type
10398 {
10399 1197433 unsigned r=zc_oldrand();
10400
10401
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10402 {
10403 17542 FireWeapon();
10404
10405
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10406
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10407 {
10408
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10409 {
10410 909 x-=4;
10411 909 FireWeapon();
10412 909 x+=4;
10413 909 }
10414 14854 }
10415
10416 17542 clk3=0;
10417 17542 }
10418 }
10419 1198479 }
10420
10421 2504746 return enemy::animate(index);
10422 2504746 }
10423
10424 2520335 void eProjectile::draw(BITMAP *dest)
10425 {
10426 2520335 update_enemy_frame();
10427 2520335 enemy::draw(dest);
10428 2520335 }
10429
10430 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10431 533 {
10432 533 hxofs=1000;
10433 533 }
10434
10435 249811 void eTrigger::draw(BITMAP *dest)
10436 {
10437 249811 update_enemy_frame();
10438 249811 enemy::draw(dest);
10439 249811 }
10440
10441 void eTrigger::death_sfx()
10442 {
10443 //silent death
10444 }
10445
10446 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10447 5 {
10448 5 o_tile+=wpnsbuf[iwNPCs].tile;
10449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10450 5 SIZEflags = d->SIZEflags;
10451
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10452 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10453 // al_trace("Enemy txsz:%i\n", txsz);
10454
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10456
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10458
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10459
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10460 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10461
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10463 {
10464 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10465 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10466 }
10467
10468
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10469 5 }
10470
10471 75 bool eNPC::animate(int32_t index)
10472 {
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10474
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10475 70 return Dead(index);
10476
10477
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10478 {
10479 removearmos(x,y,ffcactivated);
10480 }
10481
10482
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10483 {
10484 case 0:
10485 {
10486 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10487 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10488
10489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10490 {
10491 dir=down;
10492 }
10493
10494
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10495 {
10496 5 dir=right;
10497 5 }
10498 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10499 {
10500 dir=up;
10501 }
10502 else
10503 {
10504 dir=left;
10505 }
10506 }
10507 5 break;
10508
10509 case 1:
10510 halting_walk(rate, homing, 0, hrate, 48);
10511
10512 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10513 {
10514 newdir(rate, homing, 0);
10515 clk2=48;
10516 ++misc;
10517 }
10518
10519 if(clk2==0)
10520 misc=0;
10521
10522 break;
10523 }
10524
10525 5 return enemy::animate(index);
10526 75 }
10527
10528 75 void eNPC::draw(BITMAP *dest)
10529 {
10530 75 update_enemy_frame();
10531 75 enemy::draw(dest);
10532 75 }
10533
10534 int32_t eNPC::takehit(weapon*,weapon*)
10535 {
10536 return 0;
10537 }
10538
10539 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10540 94 {
10541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10542 {
10543 94 o_tile=clk;
10544 94 cs=id>>12;
10545 94 }
10546
10547 94 id=id&0xFFF;
10548 94 clk=0;
10549
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10550 94 mainguy=false;
10551 94 SIZEflags = d->SIZEflags;
10552
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10553 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10554 // al_trace("Enemy txsz:%i\n", txsz);
10555
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10559
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10560
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10561 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10562
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10564 {
10565 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10566 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10567 }
10568
10569
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10570 94 }
10571
10572 81 void eSpinTile::facehero()
10573 {
10574
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10575 {
10576
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10577 1 dir = up;
10578 else
10579 dir = down;
10580 1 }
10581 else
10582 {
10583 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10584 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10585
10586
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10587 {
10588 12 dir=l_down;
10589 12 }
10590
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10591 {
10592 1 dir=down;
10593 1 }
10594
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10595 {
10596 12 dir=r_down;
10597 12 }
10598
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10599 {
10600 6 dir=right;
10601 6 }
10602
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10603 {
10604 17 dir=r_up;
10605 17 }
10606
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10607 {
10608 8 dir=up;
10609 8 }
10610
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10611 {
10612 6 dir=l_up;
10613 6 }
10614 else
10615 {
10616 18 dir=left;
10617 }
10618 }
10619 81 }
10620
10621
10622 15539 bool eSpinTile::animate(int32_t index)
10623 {
10624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10625
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10626
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10627 {
10628 1152 return Dead(index);
10629 }
10630
10631
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10632 {
10633 1241 removearmos(x,y,ffcactivated);
10634 1241 }
10635
10636 14387 ++misc;
10637
10638
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10639 {
10640 81 facehero();
10641 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10642 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10643 81 angular=true;
10644 81 angle=ddir;
10645 81 step=zslongToFix(dstep*100);
10646 81 }
10647
10648
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10649 52 kickbucket();
10650
10651 14387 sprite::move(step);
10652 14387 return enemy::animate(index);
10653 15539 }
10654
10655 15457 void eSpinTile::draw(BITMAP *dest)
10656 {
10657 15457 update_enemy_frame();
10658 15457 y-=(misc>>4);
10659 15457 yofs+=2;
10660 15457 enemy::draw(dest);
10661 15457 yofs-=2;
10662 15457 y+=(misc>>4);
10663 15457 }
10664
10665 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10666 {
10667 15457 flip = 0;
10668 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10669 15457 yofs+=4;
10670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10671 15457 enemy::drawshadow(dest, translucent);
10672 15457 yofs-=4;
10673 15457 }
10674
10675 2765 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10676 2765 {
10677 //these are here to bypass compiler warnings about unused arguments
10678 2765 Clk=Clk;
10679 2765 mainguy=false;
10680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
2765 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10681 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10682 {
10683 clk=1;
10684 }*/
10685 //nets+880;
10686 2765 SIZEflags = d->SIZEflags;
10687
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2765 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10688 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10689 // al_trace("Enemy txsz:%i\n", txsz);
10690
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2765 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10691
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10693
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10694
1/2
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
2765 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10695
1/2
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
2765 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10696 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10697
1/4
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
2765 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10699 {
10700 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10701 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10702 }
10703
10704
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10705 2765 }
10706
10707 623626 void eZora::facehero()
10708 {
10709
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 612841 times.
623626 if(Hero.x-x==0)
10710 {
10711 10785 dir=(Hero.y+8<y)?up:down;
10712 10785 }
10713 else
10714 {
10715 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10716 612841 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10717
10718
4/4
✓ Branch 0 taken 124342 times.
✓ Branch 1 taken 488499 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 78312 times.
612841 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10719 {
10720 78312 dir=l_down;
10721 78312 }
10722
4/4
✓ Branch 0 taken 90275 times.
✓ Branch 1 taken 444254 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 44245 times.
534529 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10723 {
10724 44245 dir=down;
10725 44245 }
10726
4/4
✓ Branch 0 taken 119526 times.
✓ Branch 1 taken 370758 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 73496 times.
490284 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10727 {
10728 73496 dir=r_down;
10729 73496 }
10730
4/4
✓ Branch 0 taken 160722 times.
✓ Branch 1 taken 256066 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 114692 times.
416788 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10731 {
10732 114692 dir=right;
10733 114692 }
10734
4/4
✓ Branch 0 taken 125815 times.
✓ Branch 1 taken 176281 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 79785 times.
302096 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10735 {
10736 79785 dir=r_up;
10737 79785 }
10738
4/4
✓ Branch 0 taken 87885 times.
✓ Branch 1 taken 134426 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 41855 times.
222311 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10739 {
10740 41855 dir=up;
10741 41855 }
10742
4/4
✓ Branch 0 taken 120580 times.
✓ Branch 1 taken 59876 times.
✓ Branch 2 taken 74550 times.
✓ Branch 3 taken 46030 times.
180456 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10743 {
10744 74550 dir=l_up;
10745 74550 }
10746 else
10747 {
10748 105906 dir=left;
10749 }
10750 }
10751 623626 }
10752
10753 852265 bool eZora::animate(int32_t index)
10754 {
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 852265 times.
852265 if(switch_hooked) return enemy::animate(index);
10756
2/2
✓ Branch 0 taken 2754 times.
✓ Branch 1 taken 849511 times.
852265 if(dying)
10757 2754 return Dead(index);
10758
10759
2/2
✓ Branch 0 taken 843799 times.
✓ Branch 1 taken 5712 times.
849511 if(clk==0)
10760 {
10761 5712 removearmos(x,y,ffcactivated);
10762 5712 }
10763
10764
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 849476 times.
849511 if(watch)
10765 {
10766 35 ++clock_zoras[id];
10767 35 return true;
10768 }
10769
10770
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 623626 times.
849476 if(get_qr(qr_NEWENEMYTILES))
10771 {
10772 623626 facehero();
10773 623626 }
10774
10775
6/6
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 4963 times.
✓ Branch 2 taken 4164 times.
✓ Branch 3 taken 825736 times.
✓ Branch 4 taken 6448 times.
✓ Branch 5 taken 2965 times.
849476 switch(clk)
10776 {
10777 case 0: // reposition him
10778 {
10779 6448 int32_t t=0;
10780 6448 int32_t pos2=zc_oldrand()%160 + 16;
10781 6448 bool placed=false;
10782
10783
4/4
✓ Branch 0 taken 6383 times.
✓ Branch 1 taken 38203 times.
✓ Branch 2 taken 26108 times.
✓ Branch 3 taken 5712 times.
44586 while(!placed && t<160)
10784 {
10785 26108 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10786
5/6
✓ Branch 0 taken 6570 times.
✓ Branch 1 taken 19538 times.
✓ Branch 2 taken 6570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5647 times.
32155 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10787
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6538 times.
6570 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10788
3/4
✓ Branch 0 taken 6538 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6047 times.
✓ Branch 3 taken 6015 times.
6570 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10789 {
10790 5647 x=(pos2&15)<<4;
10791 5647 y=pos2&0xF0;
10792
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5307 times.
5647 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10793 5647 hxofs=1000; // avoid hit detection
10794 5647 stunclk=0;
10795 5647 placed=true;
10796 5647 }
10797
10798 38138 pos2+=19;
10799
10800
2/2
✓ Branch 0 taken 33615 times.
✓ Branch 1 taken 4523 times.
38138 if(pos2>=176)
10801 4523 pos2-=160;
10802
10803 38138 ++t;
10804 }
10805
10806
3/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5647 times.
5712 if(!placed || whistleclk>=88) // can't place him, he's gone
10807 65 return true;
10808
10809 }
10810 5647 break;
10811
10812 case 35:
10813
2/2
✓ Branch 0 taken 3839 times.
✓ Branch 1 taken 1361 times.
5200 if(!get_qr(qr_NEWENEMYTILES))
10814 {
10815 1361 dir=(Hero.y+8<y)?up:down;
10816 1361 }
10817
10818 5200 hxofs=0;
10819 5200 break;
10820
10821 case 35+19:
10822 4963 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10823 4963 sfx(wpnsfx(wpn),pan(int32_t(x)));
10824 4963 break;
10825
10826 case 35+66:
10827 4164 hxofs=1000;
10828 4164 break;
10829
10830 case 198:
10831 2965 clk=-1;
10832 2965 break;
10833 }
10834
10835 848675 return enemy::animate(index);
10836 851529 }
10837
10838 857650 void eZora::draw(BITMAP *dest)
10839 {
10840
2/2
✓ Branch 0 taken 16963 times.
✓ Branch 1 taken 840687 times.
857650 if(clk<3)
10841 16963 return;
10842
10843 840687 update_enemy_frame();
10844 840687 enemy::draw(dest);
10845 857650 }
10846
10847 232 bool eZora::isSubmerged() const
10848 {
10849 232 return ( clk < 3 );
10850 }
10851
10852
3/6
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50116 times.
✗ Branch 5 not taken.
100232 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10853 50116 {
10854 50116 multishot= timer = fired = dashing = 0;
10855 50116 hashero = false;
10856 50116 dummy_bool[0]=false;
10857 50116 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10858
5/6
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 49154 times.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 467 times.
50116 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10859 {
10860
2/4
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 495 times.
✗ Branch 3 not taken.
495 step=zslongToFix(dmisc10*100);
10861
10862
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 477 times.
495 if(anim==aARMOS4) o_tile+=20;
10863 495 }
10864
10865
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 49154 times.
50116 if(flags & guy_fadeflicker)
10866 {
10867 962 clk=0;
10868 962 superman = 1;
10869 962 fading=fade_flicker;
10870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10871 962 dir=down;
10872
10873
4/6
✓ Branch 0 taken 962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✓ Branch 5 taken 553 times.
962 if(!canmove(down,(zfix)8,spw_none,false))
10874
3/6
✓ Branch 0 taken 409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
409 clk3=int32_t(13.0/step);
10875 962 }
10876
2/2
✓ Branch 0 taken 49021 times.
✓ Branch 1 taken 133 times.
49154 else if(flags & guy_fadeinstant)
10877 {
10878 133 clk=0;
10879 133 }
10880
10881
1/2
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
50116 shadowdistance = 0;
10882 50116 clk4 = clk5 = 0;
10883 //nets+2380;
10884 50116 SIZEflags = d->SIZEflags;
10885
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
50116 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10886 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10887 // al_trace("Enemy txsz:%i\n", txsz);
10888
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
50116 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10889
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
50116 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10890
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
50116 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50116 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10892
1/2
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
50116 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10893
1/2
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
50116 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10894 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50116 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50116 times.
50116 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10897 {
10898 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10899 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10900 }
10901
10902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50116 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50116 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10903 50116 }
10904
10905 15799328 bool eStalfos::animate(int32_t index)
10906 {
10907
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15799072 times.
15799328 if(switch_hooked) return enemy::animate(index);
10908
3/4
✓ Branch 0 taken 15798646 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15798646 times.
15799072 if(fallclk||drownclk)
10909 {
10910 426 return enemy::animate(index);
10911 }
10912
2/2
✓ Branch 0 taken 352690 times.
✓ Branch 1 taken 15445956 times.
15798646 if(dying)
10913 {
10914
2/2
✓ Branch 0 taken 352642 times.
✓ Branch 1 taken 48 times.
352690 if(hashero)
10915 {
10916 48 Hero.setEaten(0);
10917 48 hashero=false;
10918 48 }
10919
10920
10/14
✓ Branch 0 taken 35920 times.
✓ Branch 1 taken 316770 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32235 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352690 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10921 {
10922 187 hp=-1000;
10923
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10924 187 Ewpns.add(ew);
10925 187 ew->fakez = fakez;
10926
10927
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10928 {
10929 187 ew->step=0;
10930 187 ew->id=wpn;
10931 187 ew->misc=50;
10932 187 ew->clk=48;
10933 187 }
10934
10935 187 fired=true;
10936 187 }
10937
6/6
✓ Branch 0 taken 156270 times.
✓ Branch 1 taken 196233 times.
✓ Branch 2 taken 130218 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130200 times.
✓ Branch 5 taken 18 times.
352503 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10938 {
10939
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10940 {
10941 1 int32_t wpn2 = wpn+dmisc3;
10942
10943
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10944 {
10945 wpn2=wpn;
10946 }
10947
10948 1 dummy_bool[0]=true;
10949 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10950 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10951 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10952 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10953 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10954 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10955 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10956 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10957 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10958 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10959 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10960 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10961 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10962 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10963 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10964 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10965 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10966 1 }
10967 18 }
10968
10969 352690 KillWeapon();
10970 352690 return Dead(index);
10971 }
10972 //vire split
10973 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10974 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10975
13/14
✓ Branch 0 taken 21125 times.
✓ Branch 1 taken 15424831 times.
✓ Branch 2 taken 21125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20774 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14252909 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15445956 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10976 {
10977 1677 stop_bgsfx(index);
10978 1677 int32_t kids = guys.Count();
10979 1677 int32_t id2=dmisc3;
10980
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10981 {
10982 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10983
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10984 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10985 3307 }
10986
10987
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 1 times.
1677 if(itemguy) // Hand down the carried item
10988 {
10989 1 guycarryingitem = guys.Count()-1;
10990 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10991 1 itemguy = false;
10992 1 }
10993
10994
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10995 {
10996 17 Hero.setEaten(0);
10997 17 hashero=false;
10998 17 }
10999
11000
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
11001 323 sfx(deadsfx,pan(int32_t(x)));
11002
11003 1677 return true;
11004 }
11005 /*
11006 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
11007 {
11008 stop_bgsfx(index);
11009 int32_t kids = guys.Count();
11010 int32_t id2=dmisc3;
11011
11012 for(int32_t i=0; i < dmisc4; i++)
11013 {
11014 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
11015 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
11016 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11017 }
11018
11019 if(itemguy) // Hand down the carried item
11020 {
11021 guycarryingitem = guys.Count()-1;
11022 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11023 itemguy = false;
11024 }
11025
11026 if(hashero)
11027 {
11028 Hero.setEaten(0);
11029 hashero=false;
11030 }
11031
11032 return true;
11033 }
11034 */
11035
2/2
✓ Branch 0 taken 68968 times.
✓ Branch 1 taken 15375311 times.
15444279 if(fading)
11036 {
11037
2/2
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 67777 times.
68968 if(++clk4 > 60)
11038 {
11039 1191 clk4=0;
11040 1191 superman=0;
11041 1191 fading=0;
11042
11043
4/6
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 930 times.
1191 if(flags2&cmbflag_armos && z==0 && fakez == 0)
11044 {
11045 //if a custom size (not 16px by 16px)
11046
11047 //if a custom size (not 16px by 16px)
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
930 if (ffcactivated)
11049 removearmosffc(ffcactivated-1);
11050 else
11051 {
11052
4/8
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 930 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 930 times.
930 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11053 {
11054 //zprint("spawn big enemy from armos\n");
11055 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11056 for(int32_t dx = 0; dx < tysz; dx ++)
11057 {
11058 for(int32_t dy = 0; dy < tysz; dy++)
11059 {
11060 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
11061 did_armos = false;
11062 }
11063 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
11064 did_armos = false;
11065 }
11066 for(int32_t dy = 0; dy < tysz; dy ++)
11067 {
11068 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
11069 did_armos = false;
11070 }
11071 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
11072 }
11073 930 else removearmos(x,y);
11074 }
11075 /*
11076 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11077 {
11078 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11079 for(int32_t dx = 0; dx < hxsz; dx += 16)
11080 {
11081 for(int32_t dy = 0; dy < hysz; dy += 16)
11082 {
11083 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
11084 did_armos = false;
11085 }
11086 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11087 did_armos = false;
11088 }
11089 for(int32_t dy = 0; dy < hysz; dy += 16)
11090 {
11091 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
11092 did_armos = false;
11093 }
11094 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11095 }
11096 else removearmos(x,y,ffcactivated);
11097 */
11098
11099 930 }
11100
11101 1191 clk2=0;
11102
11103 1191 newdir();
11104 1191 }
11105 67777 else return enemy::animate(index);
11106 1191 }
11107
6/8
✓ Branch 0 taken 144960 times.
✓ Branch 1 taken 15230351 times.
✓ Branch 2 taken 144960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 144960 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135643 times.
✓ Branch 7 taken 9317 times.
15375311 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
11108 9317 removearmos(x,y,ffcactivated);
11109
11110
11111
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15369295 times.
15376502 if(hashero)
11112 {
11113 7207 Hero.setX(x);
11114 7207 Hero.setY(y);
11115 7207 ++clk2;
11116
11117
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
11118 {
11119
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
11120 {
11121 case e7tEATITEMS:
11122 {
11123
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
11124 {
11125
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&ITEM_EDIBLE)
11126 22 game->set_item(i, false);
11127 5632 }
11128
11129 22 break;
11130 }
11131
11132 case e7tEATMAGIC:
11133 game->change_dmagic(-1*game->get_magicdrainrate());
11134 break;
11135
11136 case e7tEATRUPEES:
11137 game->change_drupy(-1);
11138 break;
11139 }
11140
11141 899 clk2=0;
11142 899 }
11143
11144
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
11145 6661 --clk;
11146 7207 }
11147
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14320422 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15369295 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
11148 {
11149 // Movement engine
11150
6/6
✓ Branch 0 taken 838865 times.
✓ Branch 1 taken 14097594 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14094133 times.
✓ Branch 5 taken 59 times.
14936459 if(clk>=0) switch(id>>12)
11151 {
11152 case 0: // Normal movement
11153
11154 /*
11155 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
11156 {
11157 // Overloading clk4 (Tribble clock) here...
11158 step=17/100.0;
11159 if(clk4<32) misc=1;
11160 else if(clk4<48) misc=2;
11161 else if(clk4<300) { misc=3; step = dstep/100.0; }
11162 else if(clk4<316) misc=2;
11163 else if(clk4<412) misc=1;
11164 else if(clk4<540) { misc=0; step=0; }
11165 else clk4=0;
11166 if(clk4==48) clk=0;
11167 hxofs=(misc>=2)?0:1000;
11168 if (dmisc9==e9tLEEVER)
11169 variable_walk(rate, homing, 0);
11170 else
11171 variable_walk_8(rate, homing, 4, 0);
11172 break;
11173 }
11174 */
11175
4/4
✓ Branch 0 taken 13715099 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13298023 times.
14094133 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
11176 {
11177 796110 vire_hop();
11178 796110 break;
11179 }
11180
2/2
✓ Branch 0 taken 981551 times.
✓ Branch 1 taken 12316472 times.
13298023 else if(dmisc9==e9tROPE) //Rope charge
11181 {
11182
9/10
✓ Branch 0 taken 964129 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138340 times.
✓ Branch 3 taken 825789 times.
✓ Branch 4 taken 126255 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125430 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125430 times.
981551 if(!fired && dashing && !stunclk && !watch && !frozenclock)
11183 {
11184
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116354 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125430 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
11185 {
11186
11187
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
11188 {
11189 14 hp=-1000;
11190
11191
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11192 {
11193
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
11194 14 Ewpns.add(ew);
11195 14 ew->fakez = fakez;
11196
11197
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
11198 {
11199 14 ew->step=0;
11200 14 ew->id=wpn+dmisc3;
11201 14 ew->misc=50;
11202 14 ew->clk=48;
11203 14 }
11204
11205 14 fired=true;
11206 14 }
11207 else
11208 {
11209 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
11210 Ewpns.add(ew);
11211 ew->fakez = fakez;
11212
11213 if(wpn==ewSBomb || wpn==ewBomb)
11214 {
11215 ew->step=0;
11216 ew->id=wpn;
11217 ew->misc=50;
11218 ew->clk=48;
11219 }
11220
11221 fired=true;
11222 }
11223 14 }
11224
11225 else
11226 {
11227 33 hp=-1000;
11228
11229 int32_t wpn2;
11230
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11231 33 wpn2=wpn;
11232 else
11233 wpn2=wpn;
11234
11235
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
11236 33 Ewpns.add(ew);
11237 33 ew->fakez = fakez;
11238
11239
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
11240 {
11241 33 ew->step=0;
11242 33 ew->id=wpn2;
11243 33 ew->misc=50;
11244 33 ew->clk=48;
11245 33 }
11246
11247 33 fired=true;
11248 }
11249 47 }
11250 125430 }
11251
11252 981551 charge_attack();
11253 981551 break;
11254 }
11255 /*
11256 * Boomerang-throwers have a halt count of 1
11257 * Zols have a halt count of (zc_oldrand()&7)<<4
11258 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
11259 * Everything else has 48
11260 */
11261 else
11262 {
11263
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11748053 times.
12316472 if(wpn==ewBrang) // Goriya
11264 {
11265 568419 halting_walk(rate,homing,0,hrate, 1);
11266 568419 }
11267
4/4
✓ Branch 0 taken 11602163 times.
✓ Branch 1 taken 145890 times.
✓ Branch 2 taken 4547555 times.
✓ Branch 3 taken 7054608 times.
11748053 else if(dmisc9==e9tNORMAL && wpn==0)
11268 {
11269
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6336635 times.
7054608 if(dmisc2==e2tSPLITHIT) // Zol
11270 {
11271 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
11272 717973 }
11273
4/4
✓ Branch 0 taken 1753011 times.
✓ Branch 1 taken 4583624 times.
✓ Branch 2 taken 1537120 times.
✓ Branch 3 taken 215891 times.
6336635 else if(frate<=8 && starting_hp==1) // Gel
11274 {
11275 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
11276 215891 }
11277 else // Other
11278 {
11279 6120744 halting_walk(rate,homing,0,hrate, 48);
11280 }
11281 7054608 }
11282 else // Other
11283 {
11284 4693445 halting_walk(rate,homing,0,hrate, 48);
11285 }
11286 }
11287
11288 //if not in midair, and Hero's swinging sword is nearby, jump.
11289 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
11290 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
11291 {
11292 facehero(false);
11293 sclk=16+((dir^1)<<8);
11294 fall=-FEATHERJUMP;
11295 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
11296 }*/
11297 12316472 break;
11298
11299 // Following cases are for just after creation-by-splitting.
11300 case 1:
11301
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
11302 {
11303 821 dir=up;
11304 821 step=8;
11305 821 }
11306
11307
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
11308 {
11309 2504 move(step);
11310
11311
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11312 512 dir=down;
11313 2504 }
11314
11315
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11316 {
11317
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11318 503 x+=16;
11319 790 }
11320
11321 3294 ++misc;
11322 3294 break;
11323
11324 case 2:
11325
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11326 {
11327 15 dir=down;
11328 15 step=8;
11329 15 }
11330
11331
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11332 {
11333 45 move(step);
11334 /*
11335 if(!canmove(dir,(zfix)0,0,false))
11336 dir=up;
11337 */
11338 45 }
11339
11340
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11341 {
11342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11343 14 x-=16;
11344 14 }
11345
11346 59 ++misc;
11347 59 break;
11348
11349 default:
11350
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11351 {
11352 28 dir=(zc_oldrand()%4);
11353 28 step=8;
11354 28 }
11355
11356
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11357 {
11358 83 move(step);
11359
11360
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11361 2 dir=dir^1;
11362 83 }
11363
11364
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11365 {
11366
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11367 8 x+=(dir==left ? -16 : 16);
11368 25 }
11369
11370 108 ++misc;
11371 108 break;
11372 14097594 }
11373
11374
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14911187 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14936459 if(id>>12 && misc>=4) //recently spawned by a split enemy
11375 {
11376 829 id&=0xFFF;
11377 829 step = zslongToFix(dstep*100);
11378
11379
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11380
11381
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11382
11383
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11384
11385
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11386
11387 829 misc=3;
11388 829 }
11389 14936459 }
11390 else
11391 {
11392 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11393
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11394 }
11395
11396 // Fire Zol
11397
8/8
✓ Branch 0 taken 6100125 times.
✓ Branch 1 taken 9276377 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5960844 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15376502 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11398 {
11399 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11400 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11401
11402 1102 int32_t i=Ewpns.Count()-1;
11403 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11404
11405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11406 {
11407 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11408 if ( ew->do_animation ) ew->tile+=ew->aframe;
11409 }
11410 1102 }
11411 // Goriya
11412
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14326527 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15375400 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11413 {
11414 6362 misc=index+100;
11415
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11416 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11417
11418
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11419 {
11420 257 int32_t ndir=dir;
11421
11422
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11423 {
11424 6 ndir=(Hero.y+8<y)?up:down;
11425 6 }
11426 else //turn to face Hero
11427 {
11428 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11429 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11430
11431
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11432 {
11433 13 ndir=down;
11434 13 }
11435
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11436 {
11437 68 ndir=right;
11438 68 }
11439
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11440 {
11441 48 ndir=up;
11442 48 }
11443 else
11444 {
11445 122 ndir=left;
11446 }
11447 }
11448
11449 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11450
11451
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11452 {
11453 223 dir=ndir;
11454 223 }
11455 257 }
11456 6362 }
11457
15/16
✓ Branch 0 taken 15310158 times.
✓ Branch 1 taken 58880 times.
✓ Branch 2 taken 221196 times.
✓ Branch 3 taken 15147842 times.
✓ Branch 4 taken 195078 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170186 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168774 times.
✓ Branch 9 taken 1412 times.
✓ Branch 10 taken 153626 times.
✓ Branch 11 taken 15148 times.
✓ Branch 12 taken 153626 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152682 times.
15369038 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11458
3/3
✓ Branch 0 taken 26116 times.
✓ Branch 1 taken 125660 times.
✓ Branch 2 taken 906 times.
152682 switch(dmisc1)
11459 {
11460 case e1tCONSTANT: //Deathnut
11461 {
11462 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11463
2/2
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 2581 times.
125660 if(clk5>64)
11464 {
11465 2581 clk5=0;
11466 2581 fired=false;
11467 2581 }
11468
11469 125660 clk5+=(zc_oldrand()&3);
11470
11471
4/4
✓ Branch 0 taken 76669 times.
✓ Branch 1 taken 48991 times.
✓ Branch 2 taken 25622 times.
✓ Branch 3 taken 51047 times.
125660 if((clk5>24)&&(clk5<52))
11472 {
11473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51047 times.
51047 if ( do_animation )tile+=20; //firing
11474
11475
4/4
✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 23097 times.
✓ Branch 2 taken 25124 times.
✓ Branch 3 taken 2826 times.
51047 if(!fired&&(clk5>=38))
11476 {
11477
5/10
✓ Branch 0 taken 2826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2826 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2826 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2826 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2826 times.
✗ Branch 9 not taken.
2826 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11478 2826 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11479 2826 sfx(wpnsfx(wpn),pan(int32_t(x)));
11480 2826 fired=true;
11481 2826 }
11482 51047 }
11483
11484 125660 break;
11485 }
11486
11487 case e1tFIREOCTO: //Fire Octo
11488 906 timer=zc_oldrand()%50+50;
11489 906 break;
11490
11491 default:
11492 26116 FireWeapon();
11493 26116 break;
11494 152682 }
11495
11496 /* Fire again if:
11497 * - clk2 about to run out
11498 * - not already double-firing (dmisc1 is 1)
11499 * - not carrying Hero
11500 * - one in 0xF chance
11501 */
11502
8/10
✓ Branch 0 taken 524932 times.
✓ Branch 1 taken 14851570 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520930 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15376502 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11503 {
11504 #if 1
11505 251 newdir(rate, homing, grumble);
11506 #else
11507 dir^=2;
11508 #endif
11509 251 clk2=28;
11510 251 ++multishot;
11511 251 }
11512
11513
2/2
✓ Branch 0 taken 3492313 times.
✓ Branch 1 taken 11884189 times.
15376502 if(clk2==0)
11514 {
11515 11884189 multishot = 0;
11516 11884189 }
11517
11518
2/2
✓ Branch 0 taken 15312192 times.
✓ Branch 1 taken 64310 times.
15376502 if(timer) //Fire Octo
11519 {
11520 64310 clk2=15; //this keeps the octo in place until he's done firing
11521
11522
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11523 {
11524 15752 FireBreath(false);
11525 15752 }
11526
11527 64310 --timer;
11528 64310 }
11529
11530
2/2
✓ Branch 0 taken 15127109 times.
✓ Branch 1 taken 249393 times.
15376502 if(dmisc2==e2tTRIBBLE)
11531 249393 ++clk4;
11532
11533
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15372022 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15375809 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15376502 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11534 {
11535 693 int32_t kids = guys.Count();
11536 693 int32_t id2=dmisc3;
11537
11538
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11539 {
11540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(x,y,id2,-24))
11541 {
11542
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11543 {
11544 guycarryingitem = guys.Count()-1;
11545 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11546 itemguy = false;
11547 }
11548
11549 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11550 693 }
11551 693 }
11552
11553
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11554 {
11555 Hero.setEaten(0);
11556 hashero=false;
11557 }
11558
11559 693 stop_bgsfx(index);
11560 693 return true;
11561 }
11562
11563 15375809 return enemy::animate(index);
11564 15799328 }
11565
11566 16194923 void eStalfos::draw(BITMAP *dest)
11567 {
11568 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11569 {
11570 clk4--; //Kludge
11571 return;
11572 }*/
11573
11574 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11575 {
11576 cs = dcset;
11577 }*/
11578 16194923 update_enemy_frame();
11579
11580
7/8
✓ Branch 0 taken 16194497 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16194497 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16107546 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16194923 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11581 {
11582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11583 11115 }
11584
11585 16194923 enemy::draw(dest);
11586 16194923 }
11587
11588 7494259 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11589 {
11590 7494259 int32_t tempy=yofs;
11591
11592 /*
11593 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11594 flip = 0;
11595 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11596 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11597 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11598 yofs+=(((int32_t)y+17)&0xF0)-y;
11599 yofs+=8;
11600 }
11601 */
11602
4/4
✓ Branch 0 taken 7278841 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7182640 times.
✓ Branch 3 taken 311619 times.
7494259 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11603 {
11604 311619 flip = 0;
11605 311619 int32_t fdiv = frate/4;
11606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11607
11608
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11609 311619 efrate:((clk>=(frate>>1))?1:0);
11610 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11611
11612
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11613 {
11614 311619 shadowtile+=f2;
11615 311619 }
11616 else
11617 {
11618 shadowtile+=f2?1:0;
11619 }
11620
11621 311619 yofs+=shadowdistance;
11622 311619 yofs+=8;
11623 311619 }
11624
4/4
✓ Branch 0 taken 7278841 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7491224 times.
✓ Branch 3 taken 3035 times.
7494259 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11625 {
11626 3035 flip = 0;
11627 3035 int32_t fdiv = frate/4;
11628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11629
11630
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11631 3035 efrate:((clk>=(frate>>1))?1:0);
11632 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11633
11634
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11635 {
11636 3035 shadowtile+=f2;
11637 3035 }
11638 else
11639 {
11640 shadowtile+=f2?1:0;
11641 }
11642 3035 }
11643
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7488763 times.
7494259 if(!shadow_overpit(this))
11644 7488763 enemy::drawshadow(dest, translucent);
11645 7494259 yofs=tempy;
11646 7494259 }
11647
11648 157627 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11649 {
11650 157627 int32_t wpnId = w->id;
11651 157627 int32_t wpnDir = w->dir;
11652
11653
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156209 times.
✓ Branch 2 taken 546 times.
✓ Branch 3 taken 872 times.
157627 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11654
5/8
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 185 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 185 times.
546 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
11655
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
185 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
11656 {
11657 361 shield = false;
11658 361 flags &= ~(inv_left|inv_right|inv_back|inv_front);
11659
11660
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 256 times.
361 if(get_qr(qr_BRKNSHLDTILES))
11661 256 o_tile=s_tile;
11662 361 }
11663
11664 157627 int32_t ret = enemy::takehit(w,realweap);
11665
11666
4/4
✓ Branch 0 taken 22313 times.
✓ Branch 1 taken 135314 times.
✓ Branch 2 taken 20562 times.
✓ Branch 3 taken 1751 times.
157627 if(sclk && dmisc2==e2tSPLITHIT)
11667 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11668
11669 157627 return ret;
11670 }
11671
11672 981551 void eStalfos::charge_attack()
11673 {
11674
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 974836 times.
981551 if(slide())
11675 6715 return;
11676
11677
10/12
✓ Branch 0 taken 974836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 972432 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 942919 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 921366 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 915743 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915743 times.
974836 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11678 59093 return;
11679
11680
2/2
✓ Branch 0 taken 37390 times.
✓ Branch 1 taken 878353 times.
915743 if(clk3<=0)
11681 {
11682 37390 fix_coords(true);
11683
11684
2/2
✓ Branch 0 taken 10009 times.
✓ Branch 1 taken 27381 times.
37390 if(!dashing)
11685 {
11686 27381 int32_t ldir = lined_up(7,false);
11687
11688
4/4
✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 24294 times.
✓ Branch 2 taken 2635 times.
✓ Branch 3 taken 452 times.
27381 if(ldir!=-1 && canmove(ldir,false))
11689 {
11690 2635 dir=ldir;
11691 2635 dashing=true;
11692 2635 step=zslongToFix(dstep*100)+1;
11693 2635 }
11694 24746 else newdir(4,0,0);
11695 27381 }
11696
11697
2/2
✓ Branch 0 taken 35948 times.
✓ Branch 1 taken 1442 times.
37390 if(!canmove(dir,false))
11698 {
11699 1442 step=zslongToFix(dstep*100);
11700 1442 newdir();
11701 1442 dashing=false;
11702 1442 }
11703
11704 37390 zfix div = step;
11705
11706
1/2
✓ Branch 0 taken 37390 times.
✗ Branch 1 not taken.
37390 if(div == 0)
11707 div = 1;
11708
11709 37390 clk3=(int32_t)(16.0/div);
11710 37390 return;
11711 }
11712
11713 878353 move(step);
11714 878353 --clk3;
11715 981551 }
11716
11717 796110 void eStalfos::vire_hop()
11718 {
11719 //if ( sclk > 0 ) return; //Don't hop during knockback.
11720
11721 // if(dmisc9!=e9tPOLSVOICE)
11722 // {
11723 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11724 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11725 // return; //the enemy should split if it is sliding!
11726 // //else sclk=0; //might need this here, too. -Z
11727 // }
11728
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11729 {
11730
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11731 {
11732
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11733 //return;
11734 3843 }
11735 376292 }
11736 417076 else sclk=0;
11737
11738
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11739 31892 return;
11740
11741 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11742 761476 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11743
11744 761476 y=floor_y;
11745
11746
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11747 {
11748 26258 fix_coords();
11749
11750 //z=0;
11751 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11752 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11753
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
11754 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11755
11756
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11757 {
11758 //z=0;
11759
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11760 {
11761
11762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11763 /*if (dmisc9==e9tPOLSVOICE )
11764 {
11765 zprint2("polsvoice jump_width is: %d\n", jump_width);
11766 zprint2("polsvoice raw step is: %d\n", step);
11767 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11768 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11769 }
11770 else
11771 {
11772 zprint2("vire jump_width is: %d\n", jump_width);
11773 zprint2("vire raw step is: %d\n", step);
11774 zprint2("vire step.getInt() is: %d\n", step.getInt());
11775 zprint2("setting clk2 on vire to: %d\n", clk2);
11776 }
11777 */
11778 17258 }
11779 21336 }
11780
11781
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11782 {
11783 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11784 7030 }
11785
11786 26258 clk3=int32_t(16.0/step.getFloat());
11787 26258 }
11788
11789 761476 --clk3;
11790
11791
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11792 761476 move(step);
11793
11794 761476 floor_y=y;
11795 761476 clk2--;
11796
11797 //if we're in the middle of a jump
11798
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11799 {
11800 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11801
11802
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11803 {
11804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
11805 93147 else z=h;
11806 93147 }
11807 else
11808 {
11809 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11810 //y-=h;
11811 384731 y=floor_y-h;
11812 384731 shadowdistance=h;
11813 }
11814 477878 }
11815 else
11816 283598 shadowdistance = 0;
11817 796110 }
11818
11819 138 void eStalfos::eathero()
11820 {
11821
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11822 {
11823 70 hashero=true;
11824 70 y=floor_y;
11825 70 z=0;
11826
11827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11828 {
11829 Hero.setX(x);
11830 Hero.setY(y);
11831 }
11832 else
11833 {
11834 70 x=Hero.getX();
11835 70 y=Hero.getY();
11836 }
11837
11838 70 clk2=0;
11839 70 }
11840 138 }
11841
11842 1469390 bool eStalfos::WeaponOut()
11843 {
11844
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11845 {
11846
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11847 {
11848 846991 return true;
11849 }
11850
11851 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11852 stop_sfx(bgsfx);
11853 */
11854 1553588 }
11855
11856 622399 return false;
11857 1469390 }
11858
11859 352690 void eStalfos::KillWeapon()
11860 {
11861
2/2
✓ Branch 0 taken 352690 times.
✓ Branch 1 taken 293384 times.
646074 for(int32_t i=0; i<Ewpns.Count(); i++)
11862 {
11863
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11864 {
11865 //only kill this Goriya's boomerang -DD
11866
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11867 {
11868 411 Ewpns.del(i);
11869 411 }
11870 810 }
11871 293384 }
11872
11873
4/4
✓ Branch 0 taken 26052 times.
✓ Branch 1 taken 326638 times.
✓ Branch 2 taken 14170 times.
✓ Branch 3 taken 11882 times.
352690 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11874 {
11875 14170 stop_sfx(WAV_BRANG);
11876 14170 }
11877 352690 }
11878
11879 void eStalfos::break_shield()
11880 {
11881 if(!shield)
11882 return;
11883
11884 flags&=~(inv_front | inv_back | inv_left | inv_right);
11885 shield=false;
11886
11887 if(get_qr(qr_BRKNSHLDTILES))
11888 o_tile=s_tile;
11889 }
11890
11891 13582 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11892 13582 {
11893
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 dir=(zc_oldrand()&7)+8;
11894
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 step=0;
11895 13582 movestatus=1;
11896
3/4
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10458 times.
13582 if (dmisc1 != 1 && dmisc19 > 0)
11897 {
11898 step = dmisc19/100.0;
11899 movestatus = 1;
11900 }
11901
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if (dmisc1 == 2) movestatus=2;
11902 13582 c=0;
11903 13582 SIZEflags = d->SIZEflags;
11904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
11905
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11906
11907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hit_width=12;
11908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
11909
11910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
11911
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11912
11913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hit_height=8;
11914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
11915
11916
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11917 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
11918 // al_trace("Enemy txsz:%i\n", txsz);
11919
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11920
11921
11922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
11923
11924
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11926 {
11927 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11928 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11929 }
11930
11931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11932 13582 clk4=0;
11933 //nets;
11934 13582 dummy_int[1]=0;
11935 13582 }
11936
11937 3505411 bool eKeese::animate(int32_t index)
11938 {
11939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3505411 times.
3505411 if(switch_hooked) return enemy::animate(index);
11940
2/4
✓ Branch 0 taken 3505411 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3505411 times.
3505411 if(fallclk||drownclk) return enemy::animate(index);
11941
2/2
✓ Branch 0 taken 124201 times.
✓ Branch 1 taken 3381210 times.
3505411 if(dying)
11942 124201 return Dead(index);
11943
11944
2/2
✓ Branch 0 taken 26005 times.
✓ Branch 1 taken 3355205 times.
3381210 if(clk==0)
11945 {
11946 26005 removearmos(x,y,ffcactivated);
11947 26005 }
11948
11949
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2356168 times.
3381210 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11950 {
11951 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11952 1025042 }
11953 else
11954 {
11955
1/2
✓ Branch 0 taken 2356168 times.
✗ Branch 1 not taken.
2356168 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11956 2356168 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11957 }
11958
11959
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3260872 times.
3381210 if(dmisc2 == e2tKEESETRIB)
11960 {
11961
3/4
✓ Branch 0 taken 120338 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11962 {
11963
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11964 {
11965 105 int32_t kids = guys.Count();
11966 105 bool success = false;
11967 105 int32_t id2=dmisc3;
11968 105 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11969
11970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11971 {
11972
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11973 {
11974 guycarryingitem = guys.Count()-1;
11975 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11976 itemguy = false;
11977 }
11978
11979 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11980 105 }
11981
11982 105 stop_bgsfx(index);
11983 105 return true;
11984 }
11985 else
11986 {
11987 86 clk4=0;
11988 }
11989 86 }
11990 120233 }
11991 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11992
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2414993 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3260872 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11993 {
11994
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11995 {
11996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & FLAG_USE_FAKE_Z)
11997 {
11998 fakez=int32_t(step/zslongToFix(dstep*100));
11999 // Some variance in keese flight heights when away from Hero
12000 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
12001
12002 }
12003 else
12004 {
12005 687068 z=int32_t(step/zslongToFix(dstep*100));
12006 // Some variance in keese flight heights when away from Hero
12007
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
12008 }
12009 687068 }
12010 else
12011 {
12012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & FLAG_USE_FAKE_Z)
12013 {
12014 fakez=int32_t(step/zslongToFix(dstep*100));
12015 // Some variance in keese flight heights when away from Hero
12016 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12017
12018 }
12019 else
12020 {
12021 158811 z=int32_t(step/zslongToFix(dstep*100));
12022 // Some variance in keese flight heights when away from Hero
12023
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12024 }
12025 }
12026 845879 }
12027
12028 3381105 return enemy::animate(index);
12029 3505411 }
12030
12031 2056065 void eKeese::drawshadow(BITMAP *dest, bool translucent)
12032 {
12033 2056065 int32_t tempy=yofs;
12034 2056065 flip = 0;
12035 2056065 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
12036
12037
2/2
✓ Branch 0 taken 653085 times.
✓ Branch 1 taken 1402980 times.
2056065 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
12038
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1365502 times.
2056065 if(!get_qr(qr_ENEMIESZAXIS))
12039 {
12040 1365502 yofs+=int32_t(step/zslongToFix(dstep*10));
12041 1365502 }
12042
12043
6/6
✓ Branch 0 taken 2035375 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1358555 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2056065 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
12044 2020007 enemy::drawshadow(dest, translucent);
12045 2056065 yofs=tempy;
12046 2056065 }
12047
12048 7885431 void eKeese::draw(BITMAP *dest)
12049 {
12050 7885431 update_enemy_frame();
12051 7885431 enemy::draw(dest);
12052 7885431 }
12053
12054 20081 void eWizzrobe::submerge(bool set)
12055 {
12056
2/2
✓ Branch 0 taken 19934 times.
✓ Branch 1 taken 147 times.
20081 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
12057 {
12058 19934 hxofs = set?1000:0;
12059 19934 return;
12060 }
12061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
12062 147 submerged = set;
12063
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
12064 76 hxofs+=1000;
12065 71 else hxofs -= 1000;
12066 20081 }
12067 5326 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12068 5326 {
12069 5326 hxofs = 0;
12070 5326 submerged = false;
12071
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 switch(dmisc1)
12072 {
12073 case 0:
12074 2968 submerge(true);
12075 2968 fading=fade_invisible;
12076 // Set clk to just before the 'reappear' threshold
12077
9/10
✓ Branch 0 taken 2967 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2967 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1784 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1783 times.
✓ Branch 9 taken 1 times.
2968 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
12078 2968 break;
12079
12080 default:
12081 2358 dir=(loadside==right)?right:left;
12082 2358 misc=-3;
12083 2358 break;
12084 }
12085
12086 //netst+2880;
12087 5326 charging=false;
12088 5326 firing=false;
12089 5326 fclk=0;
12090
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
12091 5326 SIZEflags = d->SIZEflags;
12092
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5326 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12093 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12094 // al_trace("Enemy txsz:%i\n", txsz);
12095
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5326 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
12097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
12098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12099
1/2
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
5326 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
12100 {
12101 hxofs = (submerged?hxofs:0)+d->hxofs;
12102 }
12103
1/2
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
5326 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12104 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12105
1/4
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5326 times.
5326 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12107 {
12108 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12109 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12110 }
12111
12112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5326 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12113 5326 }
12114
12115 2075375 bool eWizzrobe::animate(int32_t index)
12116 {
12117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2075375 times.
2075375 if(switch_hooked) return enemy::animate(index);
12118
2/4
✓ Branch 0 taken 2075375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075375 times.
2075375 if(fallclk||drownclk) return enemy::animate(index);
12119
2/2
✓ Branch 0 taken 37967 times.
✓ Branch 1 taken 2037408 times.
2075375 if(dying)
12120 {
12121 37967 return Dead(index);
12122 }
12123
12124
2/2
✓ Branch 0 taken 1970803 times.
✓ Branch 1 taken 66605 times.
2037408 if(clk==0)
12125 {
12126 66605 removearmos(x,y,ffcactivated);
12127 66605 }
12128
12129
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1018188 times.
2037408 if(dmisc1) // Floating
12130 {
12131 1019220 wizzrobe_attack();
12132 1019220 }
12133 else // Teleporting
12134 {
12135
5/6
✓ Branch 0 taken 1011104 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1000017 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1018188 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
12136 {
12137 7084 fading=0;
12138 7084 submerge(false);
12139 7084 solid_update(false);
12140 7084 }
12141
8/8
✓ Branch 0 taken 977386 times.
✓ Branch 1 taken 6199 times.
✓ Branch 2 taken 5284 times.
✓ Branch 3 taken 5122 times.
✓ Branch 4 taken 4977 times.
✓ Branch 5 taken 4222 times.
✓ Branch 6 taken 4084 times.
✓ Branch 7 taken 3830 times.
1011104 else switch(clk)
12142 {
12143 case 0:
12144
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5082 times.
6199 if(!dmisc2)
12145 {
12146 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
12147 // but should not appear on dungeon walls.
12148
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4669 times.
5082 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
12149
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4445 times.
4669 else if (editorflags&ENEMY_FLAG5)
12150 {
12151 //2.10 Windrobe
12152 //randomise location and face Hero
12153 224 int32_t t=0;
12154 224 bool placed=false;
12155
12156
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
12157 {
12158
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon())
12159 {
12160 280 x=((zc_oldrand()%12)+2)*16;
12161 280 y=((zc_oldrand()%7)+2)*16;
12162 280 }
12163 else
12164 {
12165 87 x=((zc_oldrand()%14)+1)*16;
12166 87 y=((zc_oldrand()%9)+1)*16;
12167 }
12168
12169
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12170 {
12171 224 placed=true;
12172 224 }
12173
12174 367 ++t;
12175 }
12176
12177
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12178 {
12179
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
12180 {
12181 47 dir=down;
12182 47 }
12183 else
12184 {
12185 14 dir=up;
12186 }
12187 61 }
12188 else
12189 {
12190
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
12191 {
12192 72 dir=right;
12193 72 }
12194 else
12195 {
12196 91 dir=left;
12197 }
12198 }
12199
12200
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
12201 return true;
12202
12203
12204 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
12205 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
12206 224 }
12207 4445 else place_on_axis(true, dmisc4!=0);
12208 5082 }
12209 else
12210 {
12211 1117 int32_t t=0;
12212 1117 bool placed=false;
12213
12214
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
12215 {
12216
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon())
12217 {
12218 1340 x=((zc_oldrand()%12)+2)*16;
12219 1340 y=((zc_oldrand()%7)+2)*16;
12220 1340 }
12221 else
12222 {
12223 1103 x=((zc_oldrand()%14)+1)*16;
12224 1103 y=((zc_oldrand()%9)+1)*16;
12225 }
12226
12227
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12228 {
12229 1117 placed=true;
12230 1117 }
12231
12232 2443 ++t;
12233 }
12234
12235
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12236 {
12237
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
12238 {
12239 238 dir=down;
12240 238 }
12241 else
12242 {
12243 148 dir=up;
12244 }
12245 386 }
12246 else
12247 {
12248
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
12249 {
12250 340 dir=right;
12251 340 }
12252 else
12253 {
12254 391 dir=left;
12255 }
12256 }
12257
12258
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
12259 return true;
12260 }
12261
12262 6199 fading=fade_flicker;
12263 6199 submerge(false);
12264 6199 solid_update(false);
12265 6199 break;
12266
12267 case 64:
12268 5284 fading=0;
12269 5284 charging=true;
12270 5284 break;
12271
12272 case 73:
12273 5122 charging=false;
12274 5122 firing=40;
12275 5122 break;
12276
12277 case 83:
12278 4977 wizzrobe_attack_for_real();
12279 4977 break;
12280
12281 case 119:
12282 4222 firing=false;
12283 4222 charging=true;
12284 4222 break;
12285
12286 case 128:
12287 4084 fading=fade_flicker;
12288 4084 charging=false;
12289 4084 break;
12290
12291 case 146:
12292 3830 fading=fade_invisible;
12293 3830 submerge(true);
12294 3830 solid_update(false);
12295
12296 [[fallthrough]];
12297 default:
12298
4/4
✓ Branch 0 taken 981056 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 975008 times.
✓ Branch 3 taken 6208 times.
981216 if(clk>=(146+zc_max(0,dmisc5)))
12299 6208 clk=-1;
12300
12301 981216 break;
12302 }
12303 }
12304
12305 2037408 return enemy::animate(index);
12306 2075375 }
12307
12308 7900 void eWizzrobe::wizzrobe_attack_for_real()
12309 {
12310
1/2
✓ Branch 0 taken 7900 times.
✗ Branch 1 not taken.
7900 if(wpn==0) // Edited enemies
12311 return;
12312
12313
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5917 times.
7900 if(dmisc2 == 0) //normal weapon
12314 {
12315 5917 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
12316 5917 sfx(WAV_WAND,pan(int32_t(x)));
12317 5917 }
12318
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
12319 {
12320 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12321 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12322 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12323 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12324 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12325 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12326 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12327 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12328 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12329 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12330 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12331 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12332 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12333 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12334 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12335 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12336 995 sfx(WAV_FIRE,pan(int32_t(x)));
12337
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
12338 else
12339 {
12340
3/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
507 switch(wpn)
12341 {
12342 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
12343
12344 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
12345 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
12346 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
12347 case ewRock: sfx(51,pan(int32_t(x))); break;
12348 68 case ewMagic: sfx(32,pan(int32_t(x))); break;
12349 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12350 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12351 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12352 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12353 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
12354 420 case ewFlame: sfx(13,pan(int32_t(x))); break;
12355 case ewWind: sfx(32,pan(int32_t(x))); break;
12356 case ewFlame2: sfx(13,pan(int32_t(x))); break;
12357 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
12358 case ewIce: sfx(44,pan(int32_t(x))); break;
12359 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
12360 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
12361
12362 }
12363 }
12364 995 }
12365
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12366 {
12367 971 int32_t bc=0;
12368
12369
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12370 {
12371
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12372 {
12373 5195 ++bc;
12374 5195 }
12375 10497 }
12376
12377
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12378 {
12379 963 int32_t kids = guys.Count();
12380 963 int32_t bats=(zc_oldrand()%3)+1;
12381
12382
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12383 {
12384 // Summon bats (or anything)
12385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(x,y,dmisc3,-10, this->script_UID))
12386 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12387 1965 }
12388
12389 963 sfx(WAV_FIRE,pan(int32_t(x)));
12390 963 }
12391 971 }
12392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12393 {
12394
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies()==0)
12395 {
12396 return;
12397 }
12398
12399 17 int32_t kids = guys.Count();
12400
12401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12402 {
12403 17 int32_t newguys=(zc_oldrand()%3)+1;
12404 17 bool summoned=false;
12405
12406
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12407 {
12408 32 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12409 32 int32_t x2=0;
12410 32 int32_t y2=0;
12411
12412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12413 {
12414 36 x2=16*((zc_oldrand()%12)+2);
12415 36 y2=16*((zc_oldrand()%7)+2);
12416
12417
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12418 {
12419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12420 {
12421 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12422
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
12423 {
12424 ((enemy*)guys.spr(kids+i))->fakez = 64;
12425 ((enemy*)guys.spr(kids+i))->z = 0;
12426 }
12427 32 }
12428
12429 32 summoned=true;
12430 32 break;
12431 }
12432 4 }
12433 32 }
12434
12435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12436 {
12437 17 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12438 17 }
12439 17 }
12440 17 }
12441 7900 }
12442
12443
12444 1019220 void eWizzrobe::wizzrobe_attack()
12445 {
12446
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12447 86341 return;
12448
12449
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12450 {
12451 39538 fix_coords();
12452
12453
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12454 {
12455 case 1: //walking
12456
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12457 2644 misc=0;
12458 else
12459 {
12460 10364 clk3=16;
12461
12462
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12463 {
12464 1398 wizzrobe_newdir(0);
12465 1398 }
12466 }
12467
12468 13008 break;
12469
12470 case 2: //phasing
12471 {
12472 3903 int32_t jx=x;
12473 3903 int32_t jy=y;
12474 3903 int32_t jdir=-1;
12475
12476
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12477 {
12478 case 0:
12479 484 jx-=32;
12480 484 jy-=32;
12481 484 jdir=15;
12482 484 break;
12483
12484 case 1:
12485 472 jx+=32;
12486 472 jy-=32;
12487 472 jdir=9;
12488 472 break;
12489
12490 case 2:
12491 482 jx+=32;
12492 482 jy+=32;
12493 482 jdir=11;
12494 482 break;
12495
12496 case 3:
12497 492 jx-=32;
12498 492 jy+=32;
12499 492 jdir=13;
12500 492 break;
12501 }
12502
12503
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12504 {
12505 1140 misc=3;
12506 1140 clk3=32;
12507 1140 dir=jdir;
12508 1140 break;
12509 }
12510 2763 }
12511 [[fallthrough]];
12512 case 3:
12513 3813 dir&=3;
12514 3813 misc=0;
12515 [[fallthrough]];
12516 case 0:
12517 19894 wizzrobe_newdir(64);
12518 [[fallthrough]];
12519 default:
12520
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12521 {
12522
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12523 {
12524 3265 misc=1;
12525 3265 clk3=16;
12526 3265 }
12527 else
12528 {
12529 239 wizzrobe_newdir(64);
12530 239 misc=0;
12531 239 clk3=32;
12532 }
12533 3504 }
12534 else
12535 {
12536 21886 clk3=32;
12537 }
12538
12539 25390 break;
12540 }
12541
12542
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12543 4478 ++misc;
12544 39538 }
12545
12546 932879 --clk3;
12547
12548
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12549 {
12550 case 1:
12551 case 3:
12552 248377 step=1;
12553 248377 break;
12554
12555 case 2:
12556 63903 step=0;
12557 63903 break;
12558
12559 default:
12560 620599 step=0.5;
12561 620599 break;
12562
12563 }
12564
12565 932879 move(step);
12566
12567 // if(d->misc1 && misc<=0 && clk3==28)
12568
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12569 {
12570
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12571 {
12572
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12573 {
12574 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12575 // sfx(WAV_WAND,pan(int32_t(x)));
12576 1928 wizzrobe_attack_for_real();
12577 1928 fclk=30;
12578 1928 }
12579 16835 }
12580 else
12581 {
12582
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12583 {
12584 995 wizzrobe_attack_for_real();
12585 995 fclk=30;
12586 995 }
12587 }
12588 21547 }
12589
12590
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12591 4050 misc=2;
12592
12593
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12594 3441 fix_coords();
12595
12596
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12597 {
12598
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12599 {
12600 83282 --fclk;
12601 83282 }
12602 932879 }
12603
12604 1019220 }
12605
12606 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12607 {
12608 // Wizzrobes shouldn't move to the edge of the screen;
12609 // if they're already there, they should move toward the center
12610
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12611 33 dir=right;
12612
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=224)
12613 4 dir=left;
12614
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12615 2 dir=down;
12616
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=144)
12617 5 dir=up;
12618 else
12619 21487 newdir(4,homing,spw_wizzrobe);
12620 21531 }
12621
12622 2092991 void eWizzrobe::draw(BITMAP *dest)
12623 {
12624 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12625
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1050508 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2092991 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12626 125018 return;
12627
12628 1967973 int32_t tempint=dummy_int[1];
12629 1967973 bool tempbool1=dummy_bool[1];
12630 1967973 bool tempbool2=dummy_bool[2];
12631 1967973 dummy_int[1]=fclk;
12632 1967973 dummy_bool[1]=charging;
12633 1967973 dummy_bool[2]=firing;
12634 1967973 update_enemy_frame();
12635 1967973 dummy_int[1]=tempint;
12636 1967973 dummy_bool[1]=tempbool1;
12637 1967973 dummy_bool[2]=tempbool2;
12638 1967973 enemy::draw(dest);
12639 2092991 }
12640
12641 /*********************************/
12642 /********** Bosses ***********/
12643 /*********************************/
12644
12645 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12646 203 {
12647 203 fading=fade_flash_die;
12648 //nets+5120;
12649
6/8
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12650 {
12651 3 dir=up;
12652 3 }
12653
12654
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
203 if(dir==right&&x>=208)
12655 {
12656 dir=left;
12657 }
12658 203 SIZEflags = d->SIZEflags;
12659
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
203 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12660 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12661 // al_trace("Enemy txsz:%i\n", txsz);
12662
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
203 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12666
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12667
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12668 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12669
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12671 {
12672 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12673 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12674 }
12675
12676
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
203 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12677 203 }
12678
12679 125855 bool eDodongo::animate(int32_t index)
12680 {
12681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12682
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12683 {
12684 3790 return Dead(index);
12685 }
12686
12687
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12688 {
12689 569 removearmos(x,y,ffcactivated);
12690 569 }
12691
12692
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12693 {
12694
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12695 113 hp-=misc; // store bomb's power in misc
12696 10848 }
12697 else
12698 111217 constant_walk(rate,homing,spw_clipright);
12699
12700 122065 hit_width = (dir<=down) ? 16 : 32;
12701 // hysz = (dir>=left) ? 16 : 32;
12702
12703 122065 return enemy::animate(index);
12704 125855 }
12705
12706 125845 void eDodongo::draw(BITMAP *dest)
12707 {
12708 125845 tile=o_tile;
12709
12710
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12711 {
12712 3065 enemy::drawzcboss(dest);
12713 3065 return;
12714 }
12715
12716 122780 update_enemy_frame();
12717 122780 enemy::drawzcboss(dest);
12718
12719
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12720 {
12721 71118 tile+=dummy_int[1]; //second tile is previous tile
12722 71118 xofs-=16; //new xofs change
12723 71118 enemy::drawzcboss(dest);
12724 71118 xofs+=16;
12725 71118 }
12726
12727 125845 }
12728
12729 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12730 {
12731 8218 int32_t wpnId = w->id;
12732 8218 int32_t power = w->power;
12733 8218 int32_t wpnx = w->x;
12734 8218 int32_t wpny = w->y;
12735
12736
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12737 5761 return 0;
12738
12739
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12740 {
12741 case wPhantom:
12742 return 0;
12743
12744 case wFire:
12745 case wBait:
12746 case wWhistle:
12747 case wWind:
12748 case wSSparkle:
12749 case wFSparkle:
12750 return 0;
12751
12752 case wLitBomb:
12753 case wLitSBomb:
12754
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12755 690 return 0;
12756
12757 113 clk2=96;
12758 113 misc=power;
12759
12760
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12761 3 item_set=isSBOMB100;
12762
12763 113 return 1;
12764
12765 case wBomb:
12766 case wSBomb:
12767
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12768 516 return 0;
12769
12770 975 stunclk=160;
12771 975 misc=wpnId; // store wpnId
12772 975 return 1;
12773
12774 case wSword:
12775
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12776 {
12777 88 sfx(WAV_EHIT,pan(int32_t(x)));
12778 88 hp=0;
12779 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12780 88 fading=0; // don't flash
12781 88 return 1;
12782 }
12783
12784 [[fallthrough]];
12785 default:
12786 75 sfx(WAV_CHINK,pan(int32_t(x)));
12787 75 }
12788
12789 75 return 1;
12790 8218 }
12791
12792 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12793 48 {
12794 48 fading=fade_flash_die;
12795 //nets+5180;
12796 48 previous_dir=-1;
12797
6/8
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12798 {
12799 1 dir=up;
12800 1 }
12801
12802
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
48 if(dir==right&&x>=208)
12803 {
12804 dir=left;
12805 }
12806 48 SIZEflags = d->SIZEflags;
12807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12808 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12809 // al_trace("Enemy txsz:%i\n", txsz);
12810
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12811
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12812
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12814
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12815
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12816 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12817
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12819 {
12820 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12821 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12822 }
12823
12824
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12825 48 }
12826
12827 39398 bool eDodongo2::animate(int32_t index)
12828 {
12829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12830
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12831 {
12832 1158 return Dead(index);
12833 }
12834
12835
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12836 {
12837 167 removearmos(x,y,ffcactivated);
12838 167 }
12839
12840
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12841 {
12842
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12843 42 hp-=misc; // store bomb's power in misc
12844 4032 }
12845 else
12846 34208 constant_walk(rate,homing,spw_clipbottomright);
12847
12848 38240 hit_width = (dir<=down) ? 16 : 32;
12849 38240 hit_height = (dir>=left) ? 16 : 32;
12850 38240 hxofs=(dir>=left)?-8:0;
12851 38240 hyofs=(dir<left)?-8:0;
12852
12853 38240 return enemy::animate(index);
12854 39398 }
12855
12856 39601 void eDodongo2::draw(BITMAP *dest)
12857 {
12858
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12859 {
12860 768 enemy::drawzcboss(dest);
12861 768 return;
12862 }
12863
12864 38833 int32_t tempx=xofs;
12865 38833 int32_t tempy=yofs;
12866 38833 update_enemy_frame();
12867 38833 enemy::drawzcboss(dest);
12868 38833 tile+=dummy_int[1]; //second tile change
12869 38833 xofs+=dummy_int[2]; //new xofs change
12870 38833 yofs+=dummy_int[3]; //new yofs change
12871 38833 enemy::drawzcboss(dest);
12872 38833 xofs=tempx;
12873 38833 yofs=tempy;
12874 39601 }
12875
12876 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12877 {
12878 3929 int32_t wpnId = w->id;
12879 3929 int32_t power = w->power;
12880 3929 int32_t wpnx = w->x;
12881 3929 int32_t wpny = w->y;
12882
12883
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12884 2377 return 0;
12885
12886
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12887 {
12888 case wPhantom:
12889 return 0;
12890
12891 case wFire:
12892 case wBait:
12893 case wWhistle:
12894 case wWind:
12895 case wSSparkle:
12896 case wFSparkle:
12897 346 return 0;
12898
12899 case wLitBomb:
12900 case wLitSBomb:
12901
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12902 {
12903 case up:
12904
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12905 77 return 0;
12906
12907 4 break;
12908
12909 case down:
12910
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12911 71 return 0;
12912
12913 6 break;
12914
12915 case left:
12916
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12917 66 return 0;
12918
12919 16 break;
12920
12921 case right:
12922
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12923 65 return 0;
12924
12925 16 break;
12926 }
12927
12928 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12929 // return 0;
12930 42 clk2=96;
12931 42 misc=power;
12932
12933
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12934 item_set=isSBOMB100;
12935
12936 42 return 1;
12937
12938 case wBomb:
12939 case wSBomb:
12940
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12941 {
12942 case up:
12943
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12944 84 return 0;
12945
12946 92 break;
12947
12948 case down:
12949
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12950 113 return 0;
12951
12952 55 break;
12953
12954 case left:
12955
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12956 80 return 0;
12957
12958 105 break;
12959
12960 case right:
12961
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12962 71 return 0;
12963
12964 93 break;
12965 }
12966
12967 345 stunclk=160;
12968 345 misc=wpnId; // store wpnId
12969 345 return 1;
12970
12971 case wSword:
12972
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12973 {
12974 34 sfx(WAV_EHIT,pan(int32_t(x)));
12975 34 hp=0;
12976 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12977 34 fading=0; // don't flash
12978 34 return 1;
12979 }
12980
12981 [[fallthrough]];
12982 default:
12983 158 sfx(WAV_CHINK,pan(int32_t(x)));
12984 158 }
12985
12986 158 return 1;
12987 3929 }
12988
12989 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12990 126 {
12991 //these are here to bypass compiler warnings about unused arguments
12992
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12993 {
12994
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 x = dmisc1 ? 64 : 176;
12995
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 y = 64;
12996 126 }
12997 else { x = X; y = Y; }
12998
12999 //nets+5940;
13000
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
13001 {
13002 81 }
13003 else
13004 {
13005
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 38 times.
45 if(dmisc1)
13006 {
13007 7 flip=1;
13008 7 }
13009 }
13010
13011
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13012 126 clk3=32;
13013 126 clk2=0;
13014 126 clk4=clk;
13015 126 dir=left;
13016 126 SIZEflags = d->SIZEflags;
13017
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
126 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13018 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13019 // al_trace("Enemy txsz:%i\n", txsz);
13020
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
126 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13024
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13025
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13026 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13029 {
13030 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13031 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13032 }
13033
13034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13035 126 }
13036
13037 71899 bool eAquamentus::animate(int32_t index)
13038 {
13039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
13040
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
13041 2092 return Dead(index);
13042
13043 // fbx=x+((id==eRAQUAM)?4:-4);
13044
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
13045 {
13046 317 removearmos(x,y,ffcactivated);
13047 317 }
13048
13049 69807 fbx=x;
13050
13051 /*
13052 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
13053 {
13054 fbx+=16;
13055 }
13056 */
13057
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
13058 {
13059 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
13060 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
13061 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
13062 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
13063 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
13064 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
13065 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
13066 450 }
13067
13068
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 21018 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
13069 {
13070 345 clk3=32;
13071 345 }
13072
13073
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
13074 {
13075 1117 int32_t d2=(zc_oldrand()%3)+1;
13076
13077
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
13078 {
13079 752 dir=d2;
13080 752 }
13081
13082
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 732 times.
1117 if(dmisc1)
13083 {
13084
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(x<=40)
13085 {
13086 38 dir=right;
13087 38 }
13088
13089
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(x>=104)
13090 {
13091 dir=left;
13092 }
13093 385 }
13094 else
13095 {
13096
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(x<=136)
13097 {
13098 21 dir=right;
13099 21 }
13100
13101
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(x>=200)
13102 {
13103 34 dir=left;
13104 34 }
13105 }
13106 1117 }
13107
13108
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
13109 {
13110
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
13111 {
13112 4546 x-=1;
13113 4546 }
13114 else
13115 {
13116 3995 x+=1;
13117 }
13118 8541 }
13119
13120 69807 clk4=(clk4+1)%256;
13121
13122 69807 return enemy::animate(index);
13123 71899 }
13124
13125 72310 void eAquamentus::draw(BITMAP *dest)
13126 {
13127
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
13128 {
13129 44994 xofs=(dmisc1?-16:0);
13130
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
13131
13132
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
13133 {
13134 1312 xofs=0;
13135 1312 enemy::draw(dest);
13136 1312 }
13137 else
13138 {
13139 43682 drawblock(dest,15);
13140 }
13141 44994 }
13142 else
13143 {
13144 27316 int32_t xblockofs=((dmisc1)?-16:16);
13145 27316 xofs=0;
13146
13147
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
13148 {
13149 1462 enemy::draw(dest);
13150 1462 return;
13151 }
13152
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
13153 {
13154 // face (0=firing, 2=resting)
13155 25854 tile=o_tile+((clk3>0)?0:2);
13156 25854 enemy::draw(dest);
13157 // tail (
13158 25854 tile=o_tile+((clk&16)?1:3);
13159 25854 xofs=xblockofs;
13160 25854 enemy::draw(dest);
13161 // body
13162 25854 yofs+=16;
13163 25854 xofs=0;
13164 25854 tile=o_tile+((clk&16)?20:22);
13165 25854 enemy::draw(dest);
13166 25854 xofs=xblockofs;
13167 25854 tile=o_tile+((clk&16)?21:23);
13168 25854 enemy::draw(dest);
13169 25854 yofs-=16;
13170 25854 }
13171 else enemy::draw(dest);
13172 }
13173 72310 }
13174
13175 23834 bool eAquamentus::hit(weapon *w)
13176 {
13177
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
13178
13179
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
13180 {
13181 case wBeam:
13182 case wRefBeam:
13183 case wMagic:
13184 4201 hit_height=32;
13185 4201 }
13186
13187
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
13188 23834 hit_height=16;
13189 23834 return ret;
13190
13191 23834 }
13192
13193 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
13194 93 {
13195
13196
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
13197 {
13198
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 x = 128;
13199
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 y = 48;
13200 93 }
13201 else { x = X; y = Y; }
13202
13203 93 Clk=Clk;
13204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(flags & guy_fadeflicker)
13205 {
13206 clk=0;
13207 superman = 1;
13208 fading=fade_flicker;
13209 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
13210 }
13211
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 42 times.
93 else if(flags & guy_fadeinstant)
13212 {
13213 42 clk=0;
13214 42 }
13215 93 hxofs=-16;
13216 93 hit_width=48;
13217 93 clk4=0;
13218
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13219
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
13220 93 SIZEflags = d->SIZEflags;
13221
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13222 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13223 // al_trace("Enemy txsz:%i\n", txsz);
13224
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
13225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
13226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
13227
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
13228
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
13229
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
13230 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13231
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
13232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13233 {
13234 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
13235 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13236 }
13237
13238
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
13239
13240 //nets+5340;
13241 93 }
13242
13243 70891 bool eGohma::animate(int32_t index)
13244 {
13245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
13246
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
13247 1226 return Dead(index);
13248
13249
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
13250 {
13251
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
13252 {
13253 35 clk4=0;
13254 35 superman=0;
13255 35 fading=0;
13256 35 clk=0;
13257
13258 35 }
13259 1 else return enemy::animate(index);
13260 35 }
13261
13262
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
13263 {
13264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(ffcactivated-1);
13265 else
13266 {
13267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
13268 350 did_armos = false;
13269 350 removearmos(x,y);
13270 350 did_armos = false;
13271
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
13272 }
13273 350 }
13274
13275
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
13276
13277 // Movement clk must be separate from animation clk because of the Clock item
13278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
13279 68878 clk4++;
13280
13281
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
13282 {
13283
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
13284 546 dir^=1;
13285 else
13286 486 dir=zc_oldrand()%3+1;
13287 1032 }
13288
13289
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
13290 {
13291
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
13292 {
13293 case 1:
13294 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
13295 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13296 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
13297 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
13298 235 break;
13299
13300 default:
13301
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
13302 {
13303 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13304 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
13305 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
13306 754 }
13307
13308 882 break;
13309 }
13310 1117 }
13311
13312
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
13313 {
13314
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
13315 {
13316 290 FireBreath(true);
13317 290 }
13318 2215 }
13319
13320
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
13321 34479 move((zfix)1);
13322
13323
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
13324 150 clk3=0;
13325
13326 68878 return enemy::animate(index);
13327 70891 }
13328
13329 70889 void eGohma::draw(BITMAP *dest)
13330 {
13331 70889 tile=o_tile;
13332
13333
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
13334 {
13335 2012 enemy::drawzcboss(dest);
13336 2012 return;
13337 }
13338
13339
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
13340 {
13341 ///if ( do_animation )
13342 //Yuck. Gohma can just not have this capability right now.
13343 // left side
13344 53472 xofs=-16;
13345 53472 flip=0;
13346 // if(clk&16) tile=180;
13347 // else { tile=182; flip=1; }
13348 53472 tile+=(3*((clk&48)>>4));
13349 53472 enemy::drawzcboss(dest);
13350
13351 // right side
13352 53472 xofs=16;
13353 // tile=(180+182)-tile;
13354 53472 tile=o_tile;
13355 53472 tile+=(3*((clk&48)>>4))+2;
13356 53472 enemy::drawzcboss(dest);
13357
13358 // body
13359 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
13360 53472 tile=o_tile;
13361
13362 // tile+=(3*((clk&24)>>3))+2;
13363
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
13364 2975 tile+=7;
13365
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
13366 15890 tile+=10;
13367
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
13368 2051 tile+=7;
13369 else
13370 32556 tile+=((clk3-132)&24)?4:1;
13371
13372 53472 enemy::drawzcboss(dest);
13373
13374 53472 }
13375 else
13376 {
13377 // left side
13378 15405 xofs=-16;
13379 15405 flip=0;
13380
13381
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
13382 {
13383 7790 tile+=2;
13384 7790 flip=1;
13385 7790 }
13386
13387 15405 enemy::draw(dest);
13388
13389 // right side
13390 15405 tile=o_tile;
13391 15405 xofs=16;
13392
13393
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
13394
13395 // tile=(180+182)-tile;
13396 15405 enemy::draw(dest);
13397
13398 // body
13399 15405 tile=o_tile;
13400 15405 xofs=0;
13401
13402
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
13403 912 tile+=4;
13404
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
13405 4882 tile+=5;
13406
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
13407 585 tile+=4;
13408 9026 else tile+=((clk3-132)&8)?3:1;
13409
13410 15405 enemy::draw(dest);
13411
13412 }
13413 70889 }
13414
13415 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13416 {
13417 578 int32_t wpnId = w->id;
13418 578 int32_t power = w->power;
13419 578 int32_t wpnx = w->x;
13420 578 int32_t wpnDir = w->dir;
13421 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13422
13423
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
13424 {
13425
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13426 {
13427 93 sfx(WAV_CHINK,pan(int32_t(x)));
13428 93 return 1;
13429 }
13430 328 }
13431
13432 485 return enemy::takehit(w, realweap);
13433 578 }
13434
13435 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13436 327 {
13437 327 count_enemy=(id==(id&0xFFF));
13438 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13439 327 SIZEflags = d->SIZEflags;
13440
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
327 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13441 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13442 // al_trace("Enemy txsz:%i\n", txsz);
13443
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
327 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13447
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13448
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13449 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13450
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13452 {
13453 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13454 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13455 }
13456
13457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13458 327 }
13459
13460 124050 bool eLilDig::animate(int32_t index)
13461 {
13462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13463
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13464 4410 return Dead(index);
13465
13466
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13467 {
13468 7105 removearmos(x,y,ffcactivated);
13469 7105 }
13470
13471
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13472 {
13473
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13474 1161 step+=0.25;
13475 38646 }
13476
13477 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13478 119640 return enemy::animate(index);
13479 124050 }
13480
13481 124268 void eLilDig::draw(BITMAP *dest)
13482 {
13483 124268 tile = o_tile;
13484 // tile = 160;
13485 124268 int32_t fdiv = frate/4;
13486
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13487
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13488 124268 efrate:((clk>=(frate>>1))?1:0);
13489
13490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13491 {
13492
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13493 {
13494
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13495 {
13496 case up: //u
13497 11370 flip=0;
13498 11370 break;
13499
13500 case l_up: //d
13501 10699 flip=0;
13502 10699 tile+=4;
13503 10699 break;
13504
13505 case l_down: //l
13506 10722 flip=0;
13507 10722 tile+=8;
13508 10722 break;
13509
13510 case left: //r
13511 12015 flip=0;
13512 12015 tile+=12;
13513 12015 break;
13514
13515 case r_down: //ul
13516 10070 flip=0;
13517 10070 tile+=20;
13518 10070 break;
13519
13520 case down: //ur
13521 9554 flip=0;
13522 9554 tile+=24;
13523 9554 break;
13524
13525 case r_up: //dl
13526 8255 flip=0;
13527 8255 tile+=28;
13528 8255 break;
13529
13530 case right: //dr
13531 10033 flip=0;
13532 10033 tile+=32;
13533 10033 break;
13534 }
13535
13536 91457 tile+=f2;
13537 91457 }
13538 else
13539 {
13540 32811 tile+=(clk>=6)?1:0;
13541 }
13542 124268 }
13543
13544 124268 enemy::draw(dest);
13545 124268 }
13546
13547 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13548 80 {
13549 80 superman=1;
13550
13551 80 SIZEflags = d->SIZEflags;
13552
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13553 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13554 // al_trace("Enemy txsz:%i\n", txsz);
13555
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13557 80 else hit_width=32;
13558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13559 80 else hit_height=32;
13560
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13561 80 else hzsz=16; // hard to jump.
13562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13563 80 else hxofs=-8;
13564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13565 80 else hyofs=-8;
13566 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13567
1/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13569 {
13570 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13571 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13572 }
13573
13574
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13575
13576
13577 80 }
13578
13579 29662 bool eBigDig::animate(int32_t index)
13580 {
13581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13583 return Dead(index);
13584
13585
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13586 {
13587 4104 removearmos(x,y,ffcactivated);
13588 4104 }
13589
13590
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13591 {
13592 case 0:
13593 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13594 29534 break;
13595
13596 case 1:
13597 64 ++misc;
13598 64 break;
13599
13600 case 2:
13601
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13602 {
13603 111 addenemy(x,y,dmisc1+0x1000,-15);
13604 111 }
13605
13606
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13607 {
13608 30 addenemy(x,y,dmisc2+0x1000,-15);
13609 30 }
13610
13611
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13612 {
13613 30 addenemy(x,y,dmisc3+0x1000,-15);
13614 30 }
13615
13616
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13617 {
13618 30 addenemy(x,y,dmisc4+0x1000,-15);
13619 30 }
13620
13621
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13622 {
13623 2 guycarryingitem = guys.Count()-1;
13624 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13625 2 itemguy = false;
13626 2 }
13627
13628 64 stop_bgsfx(index);
13629
13630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13631
13632 64 return true;
13633 }
13634
13635 29598 return enemy::animate(index);
13636 29662 }
13637
13638 29658 void eBigDig::draw(BITMAP *dest)
13639 {
13640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13641 {
13642 update_enemy_frame();
13643 xofs-=8;
13644 yofs-=8;
13645 drawblock(dest,15);
13646 xofs+=8;
13647 yofs+=8;
13648 return;
13649 }
13650
13651 29658 tile = o_tile;
13652 29658 int32_t fdiv = frate/4;
13653
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13654
13655
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13656 29658 efrate:((clk>=(frate>>1))?1:0);
13657
13658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13659 {
13660
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13661 {
13662
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13663 {
13664 case up: //u
13665 1688 flip=0;
13666 1688 break;
13667
13668 case l_up: //d
13669 1684 flip=0;
13670 1684 tile+=8;
13671 1684 break;
13672
13673 case l_down: //l
13674 2031 flip=0;
13675 2031 tile+=40;
13676 2031 break;
13677
13678 case left: //r
13679 1910 flip=0;
13680 1910 tile+=48;
13681 1910 break;
13682
13683 case r_down: //ul
13684 2041 flip=0;
13685 2041 tile+=80;
13686 2041 break;
13687
13688 case down: //ur
13689 2043 flip=0;
13690 2043 tile+=88;
13691
13692 2043 break;
13693
13694 case r_up: //dl
13695 1514 flip=0;
13696 1514 tile+=120;
13697 1514 break;
13698
13699 case right: //dr
13700 2241 flip=0;
13701 2241 tile+=128;
13702 2241 break;
13703 }
13704
13705 16161 tile+=(f2*2);
13706 16161 }
13707 else
13708 {
13709 13497 tile+=(f2)?0:2;
13710 13497 flip=(clk&1)?1:0;
13711 }
13712 29658 }
13713
13714 29658 xofs-=8;
13715 29658 yofs-=8;
13716 29658 drawblock(dest,15);
13717 29658 xofs+=8;
13718 29658 yofs+=8;
13719 29658 }
13720
13721 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13722 {
13723 869 int32_t wpnId = w->id;
13724
13725
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13726 64 misc=1;
13727
13728 869 return 0;
13729 }
13730
13731 /*
13732 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13733 {
13734 hxofs=hyofs=8;
13735 hzsz=16; //can't be jumped.
13736 clk2=70;
13737 misc=-1;
13738 mainguy=!getmapflag();
13739 }
13740
13741 bool eGanon::animate(int32_t index)
13742 {
13743 if(switch_hooked) return enemy::animate(index);
13744 if(dying)
13745
13746 return Dead(index);
13747
13748 if(clk==0)
13749 {
13750 removearmos(x,y,ffcactivated);
13751 }
13752
13753 switch(misc)
13754 {
13755 case -1:
13756 misc=0;
13757
13758 case 0:
13759 if(++clk2>72 && !(zc_oldrand()&3))
13760 {
13761 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13762 sfx(wpnsfx(wpn),pan(int32_t(x)));
13763 clk2=0;
13764 }
13765
13766 Stunclk=0;
13767 constant_walk(rate,homing,spw_none);
13768 break;
13769
13770 case 1:
13771 case 2:
13772 if(--Stunclk<=0)
13773 {
13774 int32_t r=zc_oldrand();
13775
13776 if(r&1)
13777 {
13778 y=96;
13779
13780 if(r&2)
13781 x=160;
13782 else
13783 x=48;
13784
13785 if(tooclose(x,y,48))
13786 x=208-x;
13787 }
13788
13789 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13790 //{
13791 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13792 // }
13793 // else
13794 // {
13795 loadpalset(csBOSS,pSprite(d->bosspal));
13796 // }
13797 misc=0;
13798 }
13799
13800 break;
13801
13802 case 3:
13803 {
13804 if(hclk>0)
13805 break;
13806
13807 misc=4;
13808 clk=0;
13809 hxofs=1000;
13810 loadpalset(9,pSprite(spPILE));
13811 music_stop();
13812 stop_sfx(WAV_ROAR);
13813
13814 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13815
13816 sfx(WAV_GANON);
13817 //Ganon's dustpile; fall in sideview. -Z
13818 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13819 dustpile->linked_parent = eeGANON;
13820 setmapflag();
13821 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13822 break;
13823 }
13824
13825 case 4:
13826 if(clk>=80)
13827 {
13828 misc=5;
13829
13830 if(getmapflag())
13831 {
13832 game->lvlitems[dlevel]|=liBOSS;
13833 //play_DmapMusic();
13834 playLevelMusic();
13835 return true;
13836 }
13837
13838 sfx(WAV_CLEARED);
13839 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13840 setmapflag();
13841 }
13842
13843 break;
13844 }
13845
13846 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13847 //{
13848 //if ( current_item_id(itype_amulet,false) >= 2 )
13849 //{
13850 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13851 //}
13852 //}
13853
13854
13855 return enemy::animate(index);
13856 }
13857
13858
13859 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13860 {
13861 //these are here to bypass compiler warnings about unused arguments
13862 int32_t wpnId = w->id;
13863 int32_t power = w->power;
13864 int32_t enemyHitWeapon = w->parentitem;
13865
13866 switch(misc)
13867 {
13868 case 0:
13869 {
13870 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13871 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13872 return 0;
13873
13874 //if we are not using the new defences, just reduce his HP
13875 if (!(editorflags & ENEMY_FLAG14))
13876 {
13877 hp-=power;
13878 if(hp>0)
13879 {
13880 misc=1;
13881 Stunclk=64;
13882 }
13883 else
13884 {
13885 loadpalset(csBOSS,pSprite(spBROWN));
13886 misc=2;
13887 Stunclk=284;
13888 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13889 }
13890
13891 sfx(WAV_EHIT,pan(int32_t(x)));
13892
13893 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13894
13895 return 1;
13896 }
13897 //otherwise, resolve his defence.
13898 else
13899 {
13900 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13901 if(hp>0)
13902 {
13903 misc=1;
13904 Stunclk=64;
13905 }
13906 else
13907 {
13908 loadpalset(csBOSS,pSprite(spBROWN));
13909 misc=2;
13910 Stunclk=284;
13911 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13912 }
13913
13914 sfx(WAV_EHIT,pan(int32_t(x)));
13915
13916 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13917
13918
13919 return 1;
13920 }
13921 }
13922 case 2:
13923 {
13924 if
13925 (
13926 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13927 || //or nothing specified, use silver arrows+
13928 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13929 )
13930 return 0;
13931 {
13932 misc=3;
13933 hclk=81;
13934 loadpalset(9,pSprite(spBROWN));
13935 return 1;
13936 }
13937
13938 }
13939 }
13940
13941 return 0;
13942 }
13943
13944 void eGanon::draw(BITMAP *dest)
13945 {
13946 switch(misc)
13947 {
13948 case 0:
13949 if((clk&3)==3)
13950 tile=(zc_oldrand()%5)*2+o_tile;
13951
13952 if(db!=999)
13953 break;
13954
13955 case 2:
13956 if(Stunclk<64 && (Stunclk&1) )
13957 {
13958 if
13959 (
13960 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13961 ||
13962 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13963 )
13964 {
13965 goto ganon_draw; //draw his weapons if we can see him
13966 }
13967 break;
13968 }
13969
13970 case -1:
13971 tile=o_tile;
13972
13973 //fall through
13974 case 1:
13975 case 3:
13976 ganon_draw:
13977 drawblock(dest,15);
13978 break;
13979
13980 case 4:
13981 draw_guts(dest);
13982 draw_flash(dest);
13983 break;
13984 }
13985
13986 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13987 {
13988 if
13989 (
13990 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13991 ||
13992 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13993 )
13994 {
13995 draw_guts(dest); //makes his shots visible, but not him
13996 draw_flash(dest);
13997 }
13998 }
13999 }
14000
14001 void eGanon::draw_guts(BITMAP *dest)
14002 {
14003 int32_t c = zc_min(clk>>3,8);
14004 tile = clk<24 ? 74 : 75;
14005 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14006 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14007 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14008 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14009 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14010 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14011 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14012 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14013 }
14014
14015 void eGanon::draw_flash(BITMAP *dest)
14016 {
14017
14018 int32_t c = clk-(clk>>2);
14019 cs = (frame&3)+6;
14020 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14021 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14022 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14023 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14024 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14025 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14026 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14027 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14028 }
14029 */
14030
14031 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14032 13 {
14033 13 hxofs=hyofs=8;
14034
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
14035 {
14036 hxofs = 4;
14037 hyofs = 4;
14038 hit_width = 24;
14039 hit_height = 24;
14040 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
14041 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
14042 }
14043 13 hzsz=16; //can't be jumped.
14044 13 clk2=70;
14045 13 misc=-1;
14046
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
14047 13 }
14048
14049 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
14050 {
14051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
14052
14053 return Dead(index);
14054
14055
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
14056 {
14057 72 removearmos(x,y,ffcactivated);
14058 72 }
14059
14060
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
14061 {
14062 case -1:
14063 13 misc=0;
14064 [[fallthrough]];
14065 case 0:
14066
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
14067 {
14068 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14069 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
14070 173 clk2=0;
14071 173 }
14072
14073 12693 Stunclk=0;
14074 12693 constant_walk(rate,homing,spw_none);
14075 12693 break;
14076
14077 case 1:
14078 case 2:
14079
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
14080 {
14081 41 int32_t r=zc_oldrand();
14082
14083
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
14084 {
14085 17 y=96;
14086
14087
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
14088 6 x=160;
14089 else
14090 11 x=48;
14091
14092
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
14093 8 x=208-x;
14094 17 }
14095
14096 41 loadpalset(csBOSS,pSprite(d->bosspal));
14097 41 misc=0;
14098 41 }
14099
14100 3607 break;
14101
14102 case 3:
14103 {
14104
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
14105 972 break;
14106
14107 12 misc=4;
14108 12 clk=0;
14109 12 hxofs=1000;
14110 12 loadpalset(9,pSprite(spPILE));
14111 12 music_stop();
14112 12 stop_sfx(WAV_ROAR);
14113
14114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
14115
14116 12 sfx(WAV_GANON);
14117 //Ganon's dustpile; fall in sideview. -Z
14118 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
14119 //dustpile->miscellaneous[31] = eeGANON;
14120
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14121 12 item *dustpile = NULL;
14122 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
14123 12 dustpile = (item *)items.spr(items.Count() - 1);
14124 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
14125 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
14126 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14127 12 break;
14128 }
14129
14130 case 4:
14131
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
14132 {
14133 12 misc=5;
14134
14135 //game->lvlitems[dlevel]|=liBOSS;
14136
14137 12 sfx(WAV_CLEARED);
14138 //Add the big TF over the ashes!
14139
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
14140 {
14141 24 item *ashes = (item*)items.spr(q);
14142
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
14143 {
14144 //Z_scripterrlog("Found correct dustpile!\n");
14145
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
14146 12 item *bigtriforce = NULL;
14147 12 bigtriforce = (item *)items.spr(items.Count() - 1);
14148 12 bigtriforce->linked_parent = eeGANON;
14149 12 }
14150 24 }
14151 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14152 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
14153 12 }
14154
14155 960 break;
14156 10 case 5: return true;
14157 }
14158
14159 18244 return enemy::animate(index);
14160 18254 }
14161
14162
14163 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
14164 {
14165 //these are here to bypass compiler warnings about unused arguments
14166 964 int32_t wpnId = w->id;
14167 964 int32_t power = w->power;
14168 964 int32_t enemyHitWeapon = w->parentitem;
14169
14170
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
14171 {
14172 case 0:
14173
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
14174 31 return 0;
14175
14176 53 hp-=power;
14177
14178
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
14179 {
14180 41 misc=1;
14181 41 Stunclk=64;
14182 41 }
14183 else
14184 {
14185 12 loadpalset(csBOSS,pSprite(spBROWN));
14186 12 misc=2;
14187 12 Stunclk=284;
14188 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
14189 }
14190
14191 53 sfx(WAV_EHIT,pan(int32_t(x)));
14192
14193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
14194
14195 53 return 1;
14196
14197 case 2:
14198
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
14199 154 return 0;
14200
14201 12 misc=3;
14202 12 hclk=81;
14203 12 loadpalset(9,pSprite(spBROWN));
14204 12 return 1;
14205 }
14206
14207 714 return 0;
14208 964 }
14209
14210 20776 void eGanon::draw(BITMAP *dest)
14211 {
14212
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
14213 {
14214 case 0:
14215
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
14216 3169 tile=(zc_oldrand()%5)*2+o_tile;
14217
14218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
14219 {
14220
14221 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14222 {
14223 int odraw = drawstyle;
14224 drawstyle = 2;
14225 drawblock(dest,15);
14226 drawstyle = odraw;
14227 }
14228 else
14229 {
14230 drawblock(dest,15);
14231 }
14232 break;
14233
14234 }
14235
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
14236 {
14237 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14238 {
14239 int odraw = drawstyle;
14240 drawstyle = 2;
14241 drawblock(dest,15);
14242 drawstyle = odraw;
14243 }
14244 else
14245 {
14246 drawblock(dest,15);
14247 }
14248 break;
14249 }
14250
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
14251 12680 break;
14252 [[fallthrough]];
14253 case 2:
14254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
14255 break;
14256 [[fallthrough]];
14257 case -1:
14258 3518 tile=o_tile;
14259
14260 [[fallthrough]];
14261 case 1:
14262 case 3:
14263 7126 drawblock(dest,15);
14264 7126 break;
14265
14266 case 4:
14267 960 draw_guts(dest);
14268 960 draw_flash(dest);
14269 960 break;
14270 }
14271 20776 }
14272
14273 960 void eGanon::draw_guts(BITMAP *dest)
14274 {
14275
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
14276 960 tile = clk<24 ? 74 : 75;
14277 960 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14278 960 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14279 960 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14280 960 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14281 960 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14282 960 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14283 960 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14284 960 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14285 960 }
14286
14287 960 void eGanon::draw_flash(BITMAP *dest)
14288 {
14289
14290 960 int32_t c = clk-(clk>>2);
14291 960 cs = (frame&3)+6;
14292 960 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14293 960 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14294 960 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14295 960 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14296 960 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14297 960 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14298 960 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14299 960 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14300 960 }
14301
14302 15 void getBigTri(int32_t id2)
14303 {
14304 /*
14305 *************************
14306 * BIG TRIFORCE SEQUENCE *
14307 *************************
14308 0 BIGTRI out, WHITE flash in
14309 4 WHITE flash out, PILE cset white
14310 8 WHITE in
14311 ...
14312 188 WHITE out
14313 191 PILE cset red
14314 200 top SHUTTER opens
14315 209 bottom SHUTTER opens
14316 */
14317 15 sfx(itemsbuf[id2].playsound);
14318 15 guys.clear();
14319
14320
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
14321 {
14322 game->lvlitems[dlevel]|=liTRIFORCE;
14323 }
14324
14325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14326
14327 15 draw_screen(tmpscr);
14328
14329
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
14330 {
14331
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
14332 {
14333
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
14334 {
14335 225 RAMpal[CSET(9)+i]=_RGB(63,63,63);
14336 225 }
14337 15 }
14338
14339
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
14340 {
14341
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
14342 {
14343
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
14344 {
14345 16200 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
14346 16200 }
14347 1080 }
14348
14349 360 refreshpal=true;
14350 360 }
14351
14352
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
14353 {
14354
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
14355 else loadlvlpal(0xB);
14356 360 }
14357
14358
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
14359 {
14360 15 loadpalset(9,pSprite(spPILE));
14361 15 }
14362
14363 2880 advanceframe(true);
14364 2880 }
14365
14366 //play_DmapMusic();
14367 15 playLevelMusic();
14368
14369
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
14370 {
14371 2 Hero.dowarp(1,0); //side warp
14372 2 }
14373 15 }
14374
14375 /**********************************/
14376 /*** Multiple-Segment Enemies ***/
14377 /**********************************/
14378
14379
14380 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
14381 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14382 618 {
14383
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
14384 {
14385
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 x=128;
14386
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 y=48;
14387 618 }
14388 //else { x = X; y = Y; }
14389
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
14390 618 superman=1;
14391 618 fading=fade_invisible;
14392 618 hxofs=1000;
14393 618 segcnt=clk;
14394 618 segid=Id|0x1000;
14395 618 clk=0;
14396
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
14397
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14398 618 tile=o_tile;
14399 618 hitdir = -1;
14400 618 stickclk = 0;
14401
14402 /*
14403 if (get_qr(qr_NEWENEMYTILES))
14404 {
14405 tile=nets+1220;
14406 }
14407 else
14408 {
14409 tile=57;
14410 }
14411 */
14412 618 }
14413
14414 244844 bool eMoldorm::animate(int32_t index)
14415 {
14416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
14417 244844 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14418
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
14419 {
14420 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14421 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14422 28475 }
14423
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
14424 {
14425 562 stickclk = 0;
14426 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14427 562 }
14428
14429
14430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
14431 {
14432 244844 removearmos(x,y,ffcactivated);
14433 244844 }
14434
14435
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
14436 {
14437
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
14438 {
14439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_neverret)
14440 129 never_return(index);
14441
14442
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14443 129 leave_item();
14444
14445 129 stop_bgsfx(index);
14446 129 return true;
14447 }
14448 2322 }
14449 else
14450 {
14451
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
14452 stunclk=0;
14453 242393 constant_walk_8_old(rate,homing,spw_floater);
14454
14455
14456 242393 misc=dir;
14457
14458 // If any higher-numbered segments were killed, segcnt can be too high,
14459 // leading to a crash
14460
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
14461 segcnt=guys.Count()-index-1;
14462
14463
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
14464 {
14465 1122281 enemy* segment=((enemy*)guys.spr(i));
14466
14467 // More validation - if segcnt was wrong, this may not
14468 // actually be a Moldorm segment
14469
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
14470 {
14471 segcnt=i-index-1;
14472 break;
14473 }
14474
14475
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
14476 {
14477 242669 x=segment->x;
14478 242669 y=segment->y;
14479 242669 }
14480
14481 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14482 //Script your own blasted segmented bosses!! -Z
14483 1122281 segment->parent_script_UID = this->script_UID;
14484
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
14485 {
14486 217733 segment->dummy_int[1]=2;
14487 217733 }
14488 else
14489 {
14490 904548 segment->dummy_int[1]=1;
14491 }
14492
14493
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
14494 {
14495 242669 segment->dummy_int[1]=0;
14496 242669 }
14497
14498
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
14499 {
14500 1016 int32_t offset=1;
14501
14502
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
14503 {
14504 // Triple-check
14505
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
14506 {
14507 segcnt=j-index+1; // Add 1 because of --segcnt below
14508 break;
14509 }
14510 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14511 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14512 1480 }
14513
14514 1016 segment->hclk=33;
14515 1016 --segcnt;
14516 1016 --i; // Recheck the same index in case multiple segments died at once
14517 1016 }
14518 1122281 }
14519
14520
2/2
✓ Branch 0 taken 242264 times.
✓ Branch 1 taken 129 times.
242393 if(segcnt==0)
14521 {
14522 129 clk2=19;
14523
14524 129 x=guys.spr(index+1)->x;
14525 129 y=guys.spr(index+1)->y;
14526 129 }
14527 }
14528
14529 244715 return false;
14530 244844 }
14531
14532 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14533 3150 {
14534
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
14535 {
14536
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 x=128;
14537
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 y=48;
14538 3150 }
14539
14540
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14541 3150 hyofs=4;
14542 3150 hit_width=hit_height=8;
14543 3150 hxofs=1000;
14544 3150 mainguy=count_enemy=false;
14545 3150 parentclk = 0;
14546 3150 bgsfx=-1;
14547 3150 flags&=~guy_neverret;
14548 //deadsfx = WAV_EDEAD;
14549 3150 isCore = false;
14550 3150 }
14551
14552 1138024 bool esMoldorm::animate(int32_t index)
14553 {
14554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
14555 // Shouldn't be possible, but better to be sure
14556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
14557 dying=true;
14558
14559
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
14560 {
14561
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
14562 15743 item_set=0;
14563
14564 15743 return Dead(index);
14565 }
14566
14567
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
14568 {
14569 1017204 hxofs=4;
14570 1017204 step=((enemy*)guys.spr(index-1))->step;
14571
14572
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
14573 {
14574 70455 misc=dir;
14575 70455 dir=((enemy*)guys.spr(index-1))->misc;
14576 //do alignment, as in parent's animation :-/ -DD
14577 70455 x.doFloor();
14578 70455 y.doFloor();
14579 70455 }
14580
14581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
14582 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14583
14584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
14585 {
14586 1017204 sprite::move(step);
14587 1017204 }
14588 1017204 }
14589
14590 1122281 return enemy::animate(index);
14591 1138024 }
14592
14593 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14594 {
14595
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
14596 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14597
14598 453 return 0;
14599 2683 }
14600
14601 1155313 void esMoldorm::draw(BITMAP *dest)
14602 {
14603 1155313 tile=o_tile;
14604 1155313 int32_t fdiv = frate/4;
14605
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14606
14607
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14608 1155313 efrate:((clk>=(frate>>1))?1:0);
14609
14610
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
14611 {
14612 1043930 tile+=dummy_int[1]*40;
14613
14614
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
14615 {
14616 102730 flip=0;
14617
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14618
14619
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
14620 tile+=4;
14621 102730 }
14622 else
14623 {
14624
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
14625 {
14626 case up: //u
14627 96530 flip=0;
14628 96530 break;
14629
14630 case l_up: //d
14631 134534 flip=0;
14632 134534 tile+=4;
14633 134534 break;
14634
14635 case l_down: //l
14636 113426 flip=0;
14637 113426 tile+=8;
14638 113426 break;
14639
14640 case left: //r
14641 124800 flip=0;
14642 124800 tile+=12;
14643 124800 break;
14644
14645 case r_down: //ul
14646 101314 flip=0;
14647 101314 tile+=20;
14648 101314 break;
14649
14650 case down: //ur
14651 99043 flip=0;
14652 99043 tile+=24;
14653 99043 break;
14654
14655 case r_up: //dl
14656 131794 flip=0;
14657 131794 tile+=28;
14658 131794 break;
14659
14660 case right: //dr
14661 139759 flip=0;
14662 139759 tile+=32;
14663 139759 break;
14664 }
14665 }
14666
14667 1043930 tile+=f2;
14668 1043930 }
14669
14670
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
14671 1049046 enemy::draw(dest);
14672 1155313 }
14673
14674 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14675 420 {
14676
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
14677 {
14678
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 x=64;
14679
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 y=80;
14680 420 }
14681 //else { x = X; y = Y; }
14682 //zprint2("lanmola index is %d\n", index);
14683 //byte legaldirs = 0;
14684 420 int32_t incr = 16;
14685 //int32_t possiiblepos = 0;
14686 //int32_t positions[8] = {0};
14687
14688 //Don't spawn in pits.
14689
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
14690 {
14691 //zprint2("Can't spawn here.\n");
14692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
14693 {
14694 //move if we spawn over a pit
14695 //check each direction
14696
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14697 {
14698 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14699
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14700 }
14701
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14702 {
14703 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14704
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
14705 }
14706
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14707 {
14708 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14709
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14710 }
14711
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14712 {
14713 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14714
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
14715 }
14716
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14717 {
14718 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14719 y -= incr; break;
14720 }
14721
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14722 {
14723 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14724 y+=incr; break;
14725 }
14726
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14727 {
14728 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14729
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14730 }
14731
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14732 {
14733 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14734 x+=incr; y+=incr; break;
14735 }
14736 34 else continue;
14737
14738 }
14739
14740 105 }
14741
14742 420 dir=up;
14743 420 superman=1;
14744 420 fading=fade_invisible;
14745 420 hxofs=1000;
14746 420 segcnt=clk;
14747 420 clk=0;
14748 //set up move history
14749
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14750
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14751 420 }
14752
14753 236907 bool eLanmola::animate(int32_t index)
14754 {
14755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14756
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14757 {
14758 40196 removearmos(x,y,ffcactivated);
14759 40196 }
14760
14761
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14762 {
14763
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14764 {
14765
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14766 86 leave_item();
14767
14768 189 stop_bgsfx(index);
14769 189 return true;
14770 }
14771
14772 3402 return false;
14773 }
14774
14775
14776 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14777 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14778 //I've added a complete movement history to this enemy to compensate -DD
14779 233316 constant_walk(rate,homing,spw_none);
14780 233316 prevState.pop_front();
14781 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14782
14783 // This could cause a crash with Moldorms. I didn't see the same problem
14784 // with Lanmolas, but it looks like it ought to be possible, so here's
14785 // the same solution. - Saf
14786
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14787 segcnt=guys.Count()-index-1;
14788
14789
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14790 {
14791 966396 enemy* segment=((enemy*)guys.spr(i));
14792
14793 // More validation in case segcnt is wrong
14794
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14795 {
14796 segcnt=i-index-1;
14797 break;
14798 }
14799
14800 966396 segment->o_tile=o_tile;
14801 966396 segment->parent_script_UID = this->script_UID;
14802
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14803 {
14804 195700 segment->dummy_int[1]=1; //tail
14805 195700 }
14806 else
14807 {
14808 770696 segment->dummy_int[1]=0;
14809 }
14810
14811
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14812 {
14813
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14814 {
14815 // Triple-check
14816
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14817 {
14818 segcnt=j-index+1; // Add 1 because of --segcnt below
14819 break;
14820 }
14821 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14822 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14823 1961 }
14824
14825 1169 ((enemy*)guys.spr(i))->hclk=33;
14826 1169 --segcnt;
14827 1169 --i; // Recheck the same index in case multiple segments died at once
14828 1169 }
14829 966396 }
14830
14831
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14832 {
14833 189 clk2=19;
14834 189 x=guys.spr(index+1)->x;
14835 189 y=guys.spr(index+1)->y;
14836 189 setmapflag(mTMPNORET);
14837 189 }
14838
14839 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14840 //which is... disastrous.
14841 233316 hp = 1;
14842 233316 return enemy::animate(index);
14843 236907 }
14844
14845 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14846 2267 {
14847
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14848 {
14849
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 x=64;
14850
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 y=80;
14851 2267 }
14852 2267 int32_t incr = 16;
14853 //Don't spawn in pits.
14854
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14855 {
14856 //zprint2("Can't spawn here.\n");
14857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14858 {
14859 //move if we spawn over a pit
14860 //check each direction
14861
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14862 {
14863 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14864
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14865 }
14866
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14867 {
14868 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14869
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14870 }
14871
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14872 {
14873 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14874
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14875 }
14876
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14877 {
14878 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14879
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14880 }
14881
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14882 {
14883 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14884 y -= incr; break;
14885 }
14886
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14887 {
14888 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14889 y+=incr; break;
14890 }
14891
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14892 {
14893 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14894
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14895 }
14896
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14897 {
14898 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14899 x+=incr; y+=incr; break;
14900 }
14901 170 else continue;
14902
14903 }
14904
14905 525 }
14906
14907 2267 hxofs=1000;
14908 2267 hit_width=8;
14909 2267 mainguy=false;
14910 2267 count_enemy=(id<0x2000)?true:false;
14911
14912 //set up move history
14913
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14914
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14915
14916 2267 bgsfx = -1;
14917 2267 isCore = false;
14918 2267 flags&=~guy_neverret;
14919 2267 }
14920
14921 985563 bool esLanmola::animate(int32_t index)
14922 {
14923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14924 // Shouldn't be possible, but who knows
14925
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14926 18 dying=true;
14927
14928
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14929 {
14930 19167 xofs=0;
14931
14932
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14933 9306 item_set=0;
14934
14935 19167 return Dead(index);
14936 }
14937
14938
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14939 {
14940 930450 hxofs=4;
14941
14942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14943 {
14944 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14945 930450 prevState.pop_front();
14946 930450 prevState.push_back(newstate);
14947 930450 x = newstate.first.first;
14948 930450 y = newstate.first.second;
14949 930450 dir = newstate.second;
14950 930450 }
14951 930450 }
14952
14953 966396 return enemy::animate(index);
14954 985563 }
14955
14956 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14957 {
14958
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14959 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14960
14961 590 return 0;
14962 2655 }
14963
14964 990931 void esLanmola::draw(BITMAP *dest)
14965 {
14966 990931 tile=o_tile;
14967 990931 int32_t fdiv = frate/4;
14968
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14969
14970
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14971 990931 efrate:((clk>=(frate>>1))?1:0);
14972
14973
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14974 {
14975
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14976 {
14977 481767 tile+=20;
14978
14979
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14980 {
14981 128742 tile+=20;
14982 128742 }
14983 481767 }
14984
14985
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14986 {
14987 case up:
14988 141419 flip=0;
14989 141419 break;
14990
14991 case down:
14992 140994 flip=0;
14993 140994 tile+=4;
14994 140994 break;
14995
14996 case left:
14997 159500 flip=0;
14998 159500 tile+=8;
14999 159500 break;
15000
15001 case right:
15002 187019 flip=0;
15003 187019 tile+=12;
15004 187019 break;
15005 }
15006
15007 628932 tile+=f2;
15008 628932 }
15009 else
15010 {
15011
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
15012 {
15013 271456 tile+=1;
15014 271456 }
15015 }
15016
15017
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
15018 953893 enemy::draw(dest);
15019 990931 }
15020
15021 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
15022 150 {
15023 //these are here to bypass compiler warnings about unused arguments
15024 150 Clk=Clk;
15025 150 superman=1;
15026
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
15027 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
15028
15029
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
15030 692 arm[i]=i;
15031
15032 150 fading=fade_blue_poof;
15033 //nets+4680;
15034 150 adjusted=false;
15035 150 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
15036
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15037 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15038 // al_trace("Enemy txsz:%i\n", txsz);
15039
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15040
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15041
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15042
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15043
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15044
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15045 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15046
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15047
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15048 {
15049 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15050 }
15051
15052
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15053 150 }
15054
15055 66494 bool eManhandla::animate(int32_t index)
15056 {
15057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
15058
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
15059 1382 return Dead(index);
15060
15061
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
15062 {
15063 2471 removearmos(x,y,ffcactivated);
15064 2471 }
15065
15066
15067 // check arm status, move dead ones to end of group
15068
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
15069 {
15070 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
15071
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
15072 {
15073
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
15074 {
15075 552 zc_swap(arm[j],arm[j+1]);
15076 552 guys.swap(index+j+1,index+j+2);
15077 552 }
15078
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
15079 {
15080 87 leave_item();
15081 87 }
15082 424 --armcnt;
15083 424 --i;
15084 424 continue;
15085 }
15086
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
15087 {
15088
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
15089 {
15090 508 cur_arm->o_tile=o_tile+40;
15091 508 cur_arm->parent_script_UID = this->script_UID;
15092 508 }
15093 else
15094 {
15095 184 cur_arm->o_tile=o_tile+160;
15096 184 cur_arm->parent_script_UID = this->script_UID;
15097 }
15098 692 }
15099 193194 }
15100
15101 65112 adjusted=true;
15102
15103 // move or die
15104
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
15105 83 hp=0;
15106 else
15107 {
15108 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
15109
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
15110
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
15111 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
15112
15113
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
15114 {
15115
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
15116 {
15117
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
15118 {
15119 case 0:
15120 38579 dy1=-24;
15121 38579 break;
15122
15123 case 1:
15124 36328 dy2=31;
15125 36328 break;
15126
15127 case 2:
15128 36250 dx1=-16;
15129 36250 break;
15130
15131 case 3:
15132 39862 dx2=31;
15133 39862 break;
15134 }
15135 151019 }
15136 53584 }
15137 else
15138 {
15139 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
15140
15141
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
15142 {
15143
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
15144 {
15145 case 0:
15146 12012 dy1=-32;
15147 12012 break;
15148
15149 case 1:
15150 7730 dy2=39;
15151 7730 break;
15152
15153 case 2:
15154 9837 dx1=-24;
15155 9837 break;
15156
15157 case 3:
15158 12596 dx2=39;
15159 12596 break;
15160 }
15161 42175 }
15162 }
15163
15164 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
15165
15166
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
15167 {
15168 193194 zfix dx=(zfix)0,dy=(zfix)0;
15169
15170
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
15171 {
15172
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
15173 {
15174 case 0:
15175 38579 dy=-16;
15176 38579 break;
15177
15178 case 1:
15179 36328 dy=16;
15180 36328 break;
15181
15182 case 2:
15183 36250 dx=-16;
15184 36250 break;
15185
15186 case 3:
15187 39862 dx=16;
15188 39862 break;
15189 }
15190 151019 }
15191 else
15192 {
15193
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
15194 {
15195 case 0:
15196 5447 dy=-24;
15197 5447 dx=-8;
15198 5447 break;
15199
15200 case 1:
15201 3986 dy=24;
15202 3986 dx=8;
15203 3986 break;
15204
15205 case 2:
15206 4163 dx=-24;
15207 4163 dy=8;
15208 4163 break;
15209
15210 case 3:
15211 6774 dx=24;
15212 6774 dy=-8;
15213 6774 break;
15214
15215 case 4:
15216 6565 dy=-24;
15217 6565 dx=8;
15218 6565 break;
15219
15220 case 5:
15221 3744 dy=24;
15222 3744 dx=-8;
15223 3744 break;
15224
15225 case 6:
15226 5674 dx=-24;
15227 5674 dy=-8;
15228 5674 break;
15229
15230 case 7:
15231 5822 dx=24;
15232 5822 dy=8;
15233 5822 break;
15234 }
15235 }
15236
15237 193194 guys.spr(index+i+1)->x = x+dx;
15238 193194 guys.spr(index+i+1)->y = y+dy;
15239 193194 }
15240 }
15241
15242 65112 return enemy::animate(index);
15243 66494 }
15244
15245
15246 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
15247 {
15248 1751 int32_t wpnId = w->id;
15249
15250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
15251 return 0;
15252
15253
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
15254 {
15255 case wBomb:
15256 case wSBomb:
15257 case wSword:
15258 case wHammer:
15259 case wWand:
15260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15261
15262 case wLitBomb:
15263 case wLitSBomb:
15264 case wBait:
15265 case wWhistle:
15266 case wFire:
15267 case wWind:
15268 case wSSparkle:
15269 case wFSparkle:
15270 case wPhantom:
15271 1709 return 0;
15272
15273 case wHookshot:
15274 case wBrang:
15275 sfx(WAV_CHINK,pan(int32_t(x)));
15276 break;
15277
15278 default:
15279
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15280 else sfx(WAV_CHINK,pan(int32_t(x)));
15281
15282 42 }
15283
15284 42 return 1;
15285 1751 }
15286
15287 66490 void eManhandla::draw(BITMAP *dest)
15288 {
15289 66490 tile=o_tile;
15290 66490 int32_t fdiv = frate/4;
15291
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15292
15293
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15294 66490 efrate:((clk>=(frate>>1))?1:0);
15295
15296
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
15297 {
15298
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
15299 {
15300
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
15301 {
15302 case up: //u
15303 4771 flip=0;
15304 4771 break;
15305
15306 case l_up: //d
15307 4640 flip=0;
15308 4640 tile+=4;
15309 4640 break;
15310
15311 case l_down: //l
15312 4995 flip=0;
15313 4995 tile+=8;
15314 4995 break;
15315
15316 case left: //r
15317 5574 flip=0;
15318 5574 tile+=12;
15319 5574 break;
15320
15321 case r_down: //ul
15322 3793 flip=0;
15323 3793 tile+=20;
15324 3793 break;
15325
15326 case down: //ur
15327 3930 flip=0;
15328 3930 tile+=24;
15329 3930 break;
15330
15331 case r_up: //dl
15332 3908 flip=0;
15333 3908 tile+=28;
15334 3908 break;
15335
15336 case right: //dr
15337 5883 flip=0;
15338 5883 tile+=32;
15339 5883 break;
15340 }
15341
15342 37494 tile+=f2;
15343 37494 enemy::draw(dest);
15344 37494 } //manhandla 2, big body
15345 else
15346 {
15347
15348
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
15349 {
15350 case up: //u
15351 1277 flip=0;
15352 1277 break;
15353
15354 case l_up: //d
15355 1360 flip=0;
15356 1360 tile+=8;
15357 1360 break;
15358
15359 case l_down: //l
15360 2242 flip=0;
15361 2242 tile+=40;
15362 2242 break;
15363
15364 case left: //r
15365 1789 flip=0;
15366 1789 tile+=48;
15367 1789 break;
15368
15369 case r_down: //ul
15370 1345 flip=0;
15371 1345 tile+=80;
15372 1345 break;
15373
15374 case down: //ur
15375 805 flip=0;
15376 805 tile+=88;
15377 805 break;
15378
15379 case r_up: //dl
15380 948 flip=0;
15381 948 tile+=120;
15382 948 break;
15383
15384 case right: //dr
15385 1542 flip=0;
15386 1542 tile+=128;
15387 1542 break;
15388 }
15389
15390 11308 tile+=(f2*2);
15391 11308 xofs-=8;
15392 11308 yofs-=8;
15393 11308 drawblock(dest,15);
15394 11308 xofs+=8;
15395 11308 yofs+=8;
15396 }
15397 48802 }
15398 else
15399 {
15400
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
15401 {
15402 17173 enemy::draw(dest);
15403 17173 }
15404 else
15405 {
15406 515 xofs-=8;
15407 515 yofs-=8;
15408 515 enemy::draw(dest);
15409 515 xofs+=16;
15410 515 enemy::draw(dest);
15411 515 yofs+=16;
15412 515 enemy::draw(dest);
15413 515 xofs-=16;
15414 515 enemy::draw(dest);
15415 515 xofs+=8;
15416 515 yofs-=8;
15417 }
15418 }
15419 66490 }
15420
15421 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15422 692 {
15423 692 id=misc=clk;
15424 692 dir = clk & 3;
15425 692 clk=0;
15426 692 mainguy=count_enemy=false;
15427 692 dummy_bool[0]=false;
15428 692 item_set=0;
15429 692 bgsfx=-1;
15430 692 deadsfx = WAV_EDEAD;
15431 692 flags &= (~guy_neverret);
15432 692 isCore = false;
15433 //Probably will be buggy. -Z 12 AUG 2020
15434 692 SIZEflags = d->SIZEflags;
15435
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
692 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15436 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15437 // al_trace("Enemy txsz:%i\n", txsz);
15438
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
692 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15440
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15442
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15443
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15444 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15445
1/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15446
1/2
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
692 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15447 {
15448 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15449 }
15450
15451
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15452 692 }
15453
15454 200202 bool esManhandla::animate(int32_t index)
15455 {
15456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
15457
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
15458 7008 return Dead(index);
15459
15460
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
15461 {
15462 12404 removearmos(x,y,ffcactivated);
15463 12404 }
15464
15465
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
15466 {
15467 27896 clk2=unsigned(zc_oldrand())%5+5;
15468 27896 clk3^=1;
15469 27896 }
15470
15471
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
15472 {
15473 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15474 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
15475 1491 }
15476
15477 193194 return enemy::animate(index);
15478 200202 }
15479
15480 200186 void esManhandla::draw(BITMAP *dest)
15481 {
15482 200186 tile=o_tile;
15483 200186 int32_t fdiv = frate/4;
15484
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15485
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15486 200186 efrate:((clk>=(frate>>1))?1:0);
15487
15488
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
15489 {
15490
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
15491 {
15492 case up:
15493 39945 break;
15494
15495 case down:
15496 36845 tile+=4;
15497 36845 break;
15498
15499 case left:
15500 39966 tile+=8;
15501 39966 break;
15502
15503 case right:
15504 41960 tile+=12;
15505 41960 break;
15506 }
15507
15508 158716 tile+=f2;
15509 158716 }
15510 else
15511 {
15512
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
15513 {
15514 case down:
15515 8961 flip=2;
15516
15517 [[fallthrough]];
15518 case up:
15519 21355 tile=(clk3)?188:189;
15520 21355 break;
15521
15522 case right:
15523 12232 flip=1;
15524 [[fallthrough]];
15525
15526 case left:
15527 20115 tile=(clk3)?186:187;
15528 20115 break;
15529 }
15530 }
15531
15532 200186 enemy::draw(dest);
15533 200186 }
15534
15535 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15536 168 {
15537
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
15538 {
15539
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 x = 120;
15540
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 y = 48;
15541 168 }
15542 else
15543 {
15544 if ( !(editorflags & ENEMY_FLAG6) )
15545 {
15546 x = X; y = Y;
15547 }
15548 else
15549 {
15550 x = X+8; y = Y;
15551 }
15552 }
15553 168 hzsz = 32; // can't be jumped.
15554 168 flameclk=0;
15555 168 misc=clk; // total head count
15556 168 clk3=clk; // live head count
15557 168 clk=0;
15558 168 clk2=60; // fire ball clock
15559 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15560
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15561 168 dir = down;
15562 168 hxofs=4;
15563 168 hit_width=8;
15564 // frate=17*4;
15565 168 fading=fade_blue_poof;
15566 //nets+5420;
15567
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
15568 {
15569 /*
15570 necktile=o_tile+8;
15571 if (dmisc3)
15572 {
15573 necktile+=8;
15574 }
15575 */
15576 133 necktile=o_tile+dmisc6;
15577 133 }
15578 else
15579 {
15580 35 necktile=s_tile;
15581 }
15582 168 }
15583
15584 155290 bool eGleeok::animate(int32_t index)
15585 {
15586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
15587
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
15588 2199 return Dead(index);
15589
15590
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
15591 {
15592 684 removearmos(x,y,ffcactivated);
15593 684 }
15594
15595 // Check if a head was killed somehow...
15596
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
15597 51372 clk3=guys.Count()-index-1;
15598
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
15599 87041 misc=guys.Count()-index-1;
15600
15601 //fix for the "kill all enemies" item
15602
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
15603 {
15604
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15605 {
15606 // I haven't seen this fail, but it seems like it ought to be
15607 // possible, so I'm checking for it. - Saf
15608
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15609 break;
15610 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15611 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15612 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15613 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15614 12 }
15615
15616 6 clk3=0;
15617
15618
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15619 {
15620
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15621 break;
15622 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15623 12 }
15624 6 }
15625
15626
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
15627 {
15628 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
15629 403171 head->dummy_int[1]=necktile;
15630 403171 head->parent_script_UID = this->script_UID;
15631
15632
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
15633 {
15634 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15635 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15636 320127 }
15637 else
15638 {
15639 83044 head->dummy_int[2]=necktile+1; //connected head tile
15640 83044 head->dummy_int[3]=necktile+2; //flying head tile
15641 }
15642
15643 403171 head->dmisc5=dmisc5; //neck segments
15644
15645 /*
15646 if (dmisc3)
15647 {
15648 head->dummy_bool[0]=true;
15649 }
15650 */
15651
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
15652 {
15653
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
15654 {
15655 1228 hp -= 1000 - head->hp;
15656 1228 hclk = 33;
15657
15658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15659
15660 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
15661 1228 }
15662
15663 5655 head->hclk = 0;
15664 5655 }
15665
15666 // Must be set in case of naughty ZScripts
15667 403171 head->hp = 1000;
15668 403171 }
15669
15670
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
15671 {
15672 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15673 415 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
15674 415 }
15675
15676
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
15677 {
15678
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
15679 {
15680 1287 int32_t i=zc_oldrand()%misc;
15681 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
15682 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15683 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
15684 1287 clk2=0;
15685 1287 }
15686 95682 }
15687 else
15688 {
15689
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
15690 {
15691 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15692 557 head->timer=zc_oldrand()%50+50;
15693 557 clk2=0;
15694 557 }
15695 }
15696
15697
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
15698 {
15699
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
15700 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15701
15702
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_neverret) never_return(index);
15703 127 }
15704
15705 153091 return enemy::animate(index);
15706 155290 }
15707
15708 1239 int32_t eGleeok::takehit(weapon*,weapon*)
15709 {
15710 1239 return 0;
15711 }
15712
15713 156918 void eGleeok::draw(BITMAP *dest)
15714 {
15715 156918 tile=o_tile;
15716
15717
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
15718 {
15719 2199 enemy::draw(dest);
15720 2199 return;
15721 }
15722
15723 154719 int32_t f=clk/17;
15724
15725
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
15726 {
15727 // body
15728 120524 xofs=-8;
15729 120524 yofs=32;
15730
15731
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
15732
15733 {
15734 case 0:
15735 9155 tile+=0;
15736 9155 break;
15737
15738 case 1:
15739 10095 tile+=2;
15740 10095 break;
15741
15742 case 2:
15743 8686 tile+=4;
15744 8686 break;
15745
15746 default:
15747 92588 tile+=6;
15748 92588 break;
15749 }
15750 120524 }
15751 else
15752 {
15753 // body
15754 34195 xofs=-8;
15755 34195 yofs=32;
15756
15757
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
15758 {
15759 case 0:
15760 2514 tile+=0;
15761 2514 break;
15762
15763 case 2:
15764 2459 tile+=4;
15765 2459 break;
15766
15767 default:
15768 29222 tile+=2;
15769 29222 break;
15770 }
15771 }
15772
15773 154719 enemy::drawblock(dest,15);
15774 156918 }
15775
15776 156918 void eGleeok::draw2(BITMAP *dest)
15777 {
15778 // the neck stub
15779 156918 tile=necktile;
15780 156918 xofs=0;
15781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15782
15783
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
15784 {
15785 122181 tile+=((clk&24)>>3);
15786 122181 }
15787
15788
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15789 {
15790
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15791 737 sprite::drawcloaked(dest);
15792 else
15793 153982 sprite::draw(dest);
15794 154719 }
15795 156918 }
15796
15797
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15798 533 {
15799
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15800
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15801 // dummy_bool[0]=false;
15802 533 timer=0;
15803 /* fixing */
15804 533 hp=1000;
15805
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15806 533 item_set=0;
15807 //x=120; y=70;
15808
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15809
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15810 533 hxofs=4;
15811 533 hit_width=8;
15812
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15813 533 clk2=clk; // how int32_t to wait before moving first time
15814 533 clk=0;
15815 533 mainguy=count_enemy=false;
15816
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15817 533 clk3=((dir&2)>>1)+2; // left or right
15818 533 dir&=1; // up or down
15819
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15820 533 isCore = false;
15821
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15822
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15823 {
15824 2132 nxoffset[i] = 0;
15825 2132 nyoffset[i] = 0;
15826
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15827
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15828 2132 }
15829
15830 533 necktile=0;
15831 //TODO compatibility? -DD
15832 /*
15833 for(int32_t i=0; i<4; i++)
15834 {
15835 nx[i]=124;
15836 ny[i]=i*6+48;
15837 }*/
15838 533 bgsfx=-1;
15839 //no need for deadsfx
15840 533 }
15841
15842 515535 bool esGleeok::animate(int32_t index)
15843 {
15844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15845 // don't call removearmos() - it's a segment.
15846
15847 515535 dmisc5=vbound(dmisc5,1,255);
15848
15849
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15850 {
15851 402762 x = (xoffset+parent->x);
15852 402762 y = (yoffset+parent->y);
15853
15854
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15855 {
15856 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15857 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15858 1611048 }
15859 402762 }
15860
15861 // set up the head tiles
15862 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15863 /*
15864 if (dummy_bool[0]) //if this is a flame gleeok
15865 {
15866 headtile+=180;
15867 }
15868 */
15869 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15870 515535 flyingheadtile=dummy_int[3];
15871
15872 // set up the neck tiles
15873 515535 necktile=dummy_int[1];
15874
15875
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15876 {
15877 402833 necktile+=((clk&24)>>3);
15878 402833 }
15879
15880 /*
15881 else
15882 {
15883 necktile=145;
15884 }
15885 */
15886 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15887
15888
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15889 {
15890 case 0: // live head
15891 // set up the attached head tiles
15892 402762 tile=headtile;
15893
15894
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15895 {
15896 319820 tile+=((clk&24)>>3);
15897 /*
15898 if (dummy_bool[0]) {
15899 tile+=1561;
15900 }
15901 */
15902 319820 }
15903
15904 /*
15905 else
15906 {
15907 tile=146;
15908 }
15909 */
15910
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15911 {
15912
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15913
15914
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15915
15916
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15917 {
15918 292 dir^=1;
15919 292 }
15920
15921 92832 zfix tempx = x;
15922 92832 zfix tempy = y;
15923
15924 92832 sprite::move(step);
15925 92832 xoffset += (x-tempx);
15926 92832 yoffset += (y-tempy);
15927
15928
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15929 {
15930 3863 clk3^=1;
15931 3863 clk2=-4;
15932 3863 }
15933 else
15934 {
15935
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15936 {
15937 978 clk3=right;
15938 978 }
15939
15940
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15941 {
15942 961 clk3=left;
15943 961 }
15944
15945
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15946 {
15947 3713 clk3^=1; // x jig
15948 3713 }
15949 else
15950 {
15951
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15952 {
15953 851 clk3^=1; // x switch back
15954 851 }
15955
15956 85256 clk2=-4;
15957 }
15958 }
15959
15960 92832 zc_swap(dir,clk3);
15961 92832 tempx = x;
15962 92832 tempy = y;
15963 92832 sprite::move(step);
15964 92832 xoffset += (x-tempx);
15965 92832 yoffset += (y-tempy);
15966 92832 zc_swap(dir,clk3);
15967
15968
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15969 {
15970 278496 nxoffset[i] = (zc_oldrand()%3);
15971 278496 nyoffset[i] = (zc_oldrand()%3);
15972 278496 }
15973 92832 }
15974
15975 402762 break;
15976
15977 case 1: // flying head
15978
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15979
15980 {
15981 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15982 105482 }
15983
15984 112071 break;
15985
15986 // the following are messages sent from the main guy...
15987 case -1: // got chopped off
15988 {
15989 300 misc=1;
15990 300 superman=1;
15991 300 hxofs=xofs=0;
15992 300 hit_width=16;
15993 300 cs=8;
15994 300 clk=-24;
15995 300 clk2=40;
15996 300 dir=(zc_oldrand()&7)+8;
15997 300 step=8.0/9.0;
15998 }
15999 300 break;
16000
16001 case -2: // the big guy is dead
16002 402 return true;
16003 }
16004
16005
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
16006 {
16007
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
16008 {
16009 4791 FireBreath(true);
16010 4791 }
16011
16012 40125 --timer;
16013 40125 }
16014
16015 515133 return enemy::animate(index);
16016 515535 }
16017
16018 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
16019 {
16020
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
16021 {
16022 int32_t wpnId = w->id;
16023
16024 if(dying)
16025 return 0;
16026
16027 switch(wpnId)
16028 {
16029 case wLitBomb:
16030 case wLitSBomb:
16031 case wBait:
16032 case wWhistle:
16033 case wFire:
16034 case wWind:
16035 case wSSparkle:
16036 case wFSparkle:
16037 case wPhantom:
16038 return 0;
16039
16040 case wHookshot:
16041 case wBrang:
16042 case wBeam:
16043 case wArrow:
16044 case wMagic:
16045 case wBomb:
16046 case wSBomb:
16047 sfx(WAV_CHINK,pan(int32_t(x)));
16048 break;
16049 default:
16050 break;
16051 }
16052
16053 return 1;
16054 }
16055 else
16056 {
16057 7080 int32_t ret = enemy::takehit(w,realweap);
16058
16059
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
16060 5655 return 2; // force it to wait a frame before checking sword attacks again
16061
16062 1425 return ret;
16063 }
16064 7080 }
16065
16066 521456 void esGleeok::draw(BITMAP *dest)
16067 {
16068 521456 dmisc5=vbound(dmisc5,1,255);
16069
16070
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
16071 {
16072 case 0: //neck
16073
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
16074 {
16075
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
16076 {
16077
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
16078 {
16079
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16080 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
16081 else
16082 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
16083 978198 }
16084 else
16085 {
16086
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16087 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
16088 else
16089 249120 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
16090 }
16091 1227318 }
16092 409106 }
16093
16094 409106 break;
16095
16096 case 1: //flying head
16097 112350 tile=flyingheadtile;
16098
16099
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
16100 {
16101 82692 tile+=((clk&24)>>3);
16102 82692 break;
16103 }
16104
16105 /*
16106 else
16107 {
16108 tile=(clk&1)?147:148;
16109 break;
16110 }
16111 */
16112 29658 }
16113 521456 }
16114
16115 521456 void esGleeok::draw2(BITMAP *dest)
16116 {
16117 521456 enemy::draw(dest);
16118 521456 }
16119
16120 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
16121 190 {
16122
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
16123 {
16124
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
16125
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
16126 190 }
16127 else { x = X; y = Y; }
16128 190 adjusted=false;
16129
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
16130 //step=0.25;
16131 190 flycnt=dmisc1;
16132 190 flycnt2=dmisc2;
16133 190 loopcnt=0;
16134 190 clk4 = 0;
16135 190 clk5 = 0;
16136 190 clk6 = 0;
16137 190 clk7 = 0;
16138
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16139 190 SIZEflags = d->SIZEflags;
16140
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16141
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16142 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16143 // al_trace("Enemy txsz:%i\n", txsz);
16144
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
16145
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
16147
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16148
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
16149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
16150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
16151
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16152
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
16153 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16154
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
16155
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16157 {
16158 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16159 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
16160 }
16161
1/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
16162
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16163
16164
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
16165
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
16167 {
16168
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
16169 {
16170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
16171 105 else dmisc29 = (84 / 3);
16172 105 }
16173 else
16174 {
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
16176 85 else dmisc29 = (84 / 2);
16177 }
16178 190 }
16179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
16180 {
16181
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
16182 {
16183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
16184 105 else dmisc30 = (84 / 3)*0.5;
16185 105 }
16186 else
16187 {
16188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
16189 85 else dmisc30 = (84 / 2)*0.5;
16190 }
16191 190 }
16192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
16193 {
16194
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
16195 {
16196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
16197 105 else dmisc31 = (84 / 3)*2;
16198 105 }
16199 else
16200 {
16201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
16202 85 else dmisc31 = (84 / 2)*0.5;
16203 }
16204 190 }
16205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
16206 {
16207
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
16208 {
16209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
16210 105 else dmisc32 = (84 / 3);
16211 105 }
16212 else
16213 {
16214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
16215 85 else dmisc32 = (84 / 2)*0.25;
16216 }
16217 190 }
16218 190 }
16219
16220 161885 bool ePatra::animate(int32_t index)
16221 {
16222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
16223
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
16224 {
16225
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
16226 {
16227 72 ((enemy*)guys.spr(i))->hp = -1000;
16228 72 }
16229
16230 1444 return Dead(index);
16231 }
16232
16233 160441 double basesize = 84;
16234
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
16235 160441 double halfsize = basesize / 2;
16236 160441 double quartersize = halfsize / 2;
16237 160441 double twothirdsize = (basesize / 3)*2;
16238 160441 double onethirdsize = (basesize / 3);
16239
16240
16241
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
16242 {
16243 36934 removearmos(x,y,ffcactivated);
16244 36934 }
16245
16246
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
16247 {
16248
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
16249
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
16250
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
16251 {
16252 1797 clk2=0;
16253
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
16254 {
16255
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
16256 932 --loopcnt;
16257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
16258 {
16259
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
16260 {
16261
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
16262 356 else loopcnt=dmisc7;
16263 356 }
16264 865 }
16265 else if (loopcnt == -1) loopcnt=dmisc7;
16266 else ++loopcnt;
16267
16268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
16269 1797 }
16270 else
16271 {
16272 loopcnt = 0;
16273 misc = 1;
16274 }
16275 1797 }
16276 160441 }
16277
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
16278
16279
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
16280 {
16281 if (dmisc5 == 1 || dmisc5 == 3)
16282 {
16283 if (get_qr(qr_NEWENEMYTILES))
16284 {
16285 if (clk7 <= 0 || clk6 != -16) ++clk6;
16286 if (clk6 == 0) o_tile=d->e_tile;
16287 else
16288 {
16289 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
16290 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
16291 }
16292 }
16293 else clk6 = 0;
16294 }
16295 }
16296
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
16297
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
16298
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
16299
16300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
16301
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
16302
16303
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
16304 {
16305 //outside ring
16306
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
16307 {
16308
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
16309 {
16310 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
16311 1152 enemy *s = ((enemy*)guys.spr(i));
16312 1152 s->parent_script_UID = this->script_UID;
16313 1152 }
16314 else
16315 {
16316 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16317 192 enemy *s = ((enemy*)guys.spr(i));
16318 192 s->parent_script_UID = this->script_UID;
16319 }
16320
16321 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
16322 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
16323 1344 }
16324
16325
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
16326 {
16327
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16328 {
16329 2889 guys.swap(j,j+1);
16330 2889 }
16331
16332
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
16333 764 }
16334 else
16335 {
16336 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16337
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
16338
16339
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
16340 {
16341 //maybe playing_field_offset here?
16342
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
16343 {
16344
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16345
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16346 237330 }
16347 else
16348 {
16349 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16350 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16351 }
16352
16353 447583 temp_x=guys.spr(i)->x;
16354 447583 temp_y=guys.spr(i)->y;
16355 447583 }
16356 else //Oval
16357 {
16358 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16359 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16360
16361
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
16362 {
16363 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16364
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
16365 121041 }
16366 else
16367 {
16368 90996 guys.spr(i)->x = circle_x;
16369 90996 guys.spr(i)->y = circle_y;
16370 }
16371
16372 212037 temp_x=circle_x;
16373 212037 temp_y=circle_y;
16374 }
16375
16376 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16377 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16378
16379
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16380 {
16381 83117 guys.spr(i)->dir=l_down;
16382 83117 }
16383
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16384 {
16385 83568 guys.spr(i)->dir=left;
16386 83568 }
16387
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16388 {
16389 82454 guys.spr(i)->dir=l_up;
16390 82454 }
16391
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16392 {
16393 82188 guys.spr(i)->dir=up;
16394 82188 }
16395
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16396 {
16397 81600 guys.spr(i)->dir=r_up;
16398 81600 }
16399
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16400 {
16401 81993 guys.spr(i)->dir=right;
16402 81993 }
16403
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16404 {
16405 81699 guys.spr(i)->dir=r_down;
16406 81699 }
16407 else
16408 {
16409 83001 guys.spr(i)->dir=down;
16410 }
16411
16412 659620 guys.spr(i)->x += x;
16413 659620 guys.spr(i)->y += y;
16414 }
16415 660384 }
16416
16417
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
16418 {
16419 32331 int timeneeded = 48;
16420 32331 int patbreath = (zc_oldrand()%50+50);
16421
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
16422
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
16423 {
16424 timeneeded = 48 + patbreath;
16425 }
16426
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
16427 {
16428 timeneeded = 48 + 96;
16429 }
16430
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
16431
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
16432
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16433 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
16434 249 && (clk6 >= 0) //if not in the middle of firing...
16435 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
16436
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
16437 {
16438
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
16439 {
16440 case patratSTREAM:
16441 {
16442 clk7 = 97;
16443 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16444 else clk6 = 0;
16445 break;
16446 }
16447 case patratBREATH:
16448 {
16449 clk7 = patbreath;
16450 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16451 else clk6 = 0;
16452 break;
16453 }
16454 default:
16455 {
16456
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16457 {
16458 clk6 = -48;
16459 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16460 }
16461 else
16462 {
16463 249 clk6 = 0;
16464
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16465 249 FirePatraWeapon();
16466 }
16467 249 break;
16468 }
16469 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16470 249 }
16471
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
16472 {
16473 switch(dmisc28)
16474 {
16475 case patratSTREAM:
16476 {
16477 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
16478 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16479 break;
16480 }
16481 case patratBREATH:
16482 {
16483 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
16484 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16485 break;
16486 }
16487 default:
16488 {
16489 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
16490 {
16491 FirePatraWeapon();
16492 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16493 }
16494 break;
16495 }
16496 }
16497 }
16498 32331 }
16499
16500 160441 int randattempts = 0;
16501 160441 int randeye = 0;
16502
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
16503 {
16504 46240 do
16505 {
16506
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16507 46240 randeye += (index + flycnt + 1);
16508 46240 ++randattempts;
16509
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16510 46240 }
16511 160441 bool dofire = false;
16512
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
16513 {
16514 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16515 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16516 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16517 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16518 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16519 {
16520 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16521 {
16522 if (clk5 >= dmisc19)
16523 {
16524 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16525 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16526 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16527 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16528 || dmisc18 == -1)
16529 dofire = true;
16530 }
16531 }
16532 }
16533 }
16534
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
16535 {
16536
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16537 {
16538
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
16539 {
16540 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16541
16542
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
16543 {
16544
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16545 {
16546
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
16547 {
16548 // Center eye shoots projectiles; make room for its firing tiles
16549 case 1:
16550 case 3:
16551 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16552 144 break;
16553
16554 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16555 default:
16556 case 2:
16557 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16558 168 break;
16559 }
16560 312 }
16561 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16562 312 }
16563 else
16564 {
16565 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16566 }
16567
16568 312 ((enemy*)guys.spr(i))->cs=dmisc9;
16569
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16570 312 }
16571
16572
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
16573 {
16574 263816 ((enemy*)guys.spr(i))->superman=true;
16575 263816 }
16576 else
16577 {
16578 70613 ((enemy*)guys.spr(i))->superman=false;
16579 }
16580
16581
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
16582 {
16583
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16584 {
16585 269 guys.swap(j,j+1);
16586 269 }
16587
16588
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16589 145 }
16590 else
16591 {
16592 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16593
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16594
16595
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
16596 {
16597
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
16598 {
16599
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16600
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16601 168378 }
16602 else
16603 {
16604 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16605 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16606 }
16607
16608 327025 temp_x=guys.spr(i)->x;
16609 327025 temp_y=guys.spr(i)->y;
16610 327025 }
16611 else
16612 {
16613 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16614 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16615
16616
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16617 {
16618 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16619
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16620 3965 }
16621 else
16622 {
16623 3294 guys.spr(i)->x = circle_x;
16624 3294 guys.spr(i)->y = circle_y;
16625 }
16626
16627 7259 temp_x=circle_x;
16628 7259 temp_y=circle_y;
16629 }
16630
16631 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16632 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16633
16634
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16635 {
16636 41746 guys.spr(i)->dir=l_down;
16637 41746 }
16638
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16639 {
16640 41734 guys.spr(i)->dir=left;
16641 41734 }
16642
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16643 {
16644 41742 guys.spr(i)->dir=l_up;
16645 41742 }
16646
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16647 {
16648 41758 guys.spr(i)->dir=up;
16649 41758 }
16650
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16651 {
16652 41830 guys.spr(i)->dir=r_up;
16653 41830 }
16654
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16655 {
16656 41824 guys.spr(i)->dir=right;
16657 41824 }
16658
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16659 {
16660 41852 guys.spr(i)->dir=r_down;
16661 41852 }
16662 else
16663 {
16664 41798 guys.spr(i)->dir=down;
16665 }
16666
16667 334284 guys.spr(i)->x += x;
16668 334284 guys.spr(i)->y = y-guys.spr(i)->y;
16669
16670
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16671 {
16672 /*
16673 if(!(zc_oldrand()&127))
16674 {
16675 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16676 sfx(wpnsfx(wpn),pan(int32_t(x)));
16677 }
16678 */
16679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16680 {
16681 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16682 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16683 {
16684 if (dmisc5 == 3)
16685 {
16686 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16687 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16688 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16689 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16690 }
16691 else
16692 {
16693 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16694 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16695 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16696 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16697 }
16698 }
16699 else
16700 {
16701 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16702 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16703 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16704 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16705 }
16706 }
16707
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16708
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16709
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16710 {
16711
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
16712 {
16713 case 4: //Single one rapidfires
16714 {
16715 if (dofire && i == randeye)
16716 {
16717 ((esPatra*)guys.spr(i))->clk5 = -16;
16718 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16719 ((esPatra*)guys.spr(i))->clk4 = 96;
16720 clk5 = -3;
16721 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16722 }
16723 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16724 {
16725 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16726 sfx(wpnsfx(wpn),pan(int32_t(x)));
16727 }
16728 break;
16729 }
16730 case 3: //Ring
16731 {
16732 if (dofire)
16733 {
16734 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16735 {
16736 ((esPatra*)guys.spr(i))->clk5 = -48;
16737 clk5 = -48;
16738 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16739 }
16740 else
16741 {
16742 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16743 sfx(wpnsfx(wpn),pan(int32_t(x)));
16744 int32_t m=Ewpns.Count()-1;
16745 weapon *ew = (weapon*)(Ewpns.spr(m));
16746
16747 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16748 ((esPatra*)guys.spr(i))->clk5 = 0;
16749 clk5 = 0;
16750 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16751 }
16752 }
16753 if (((esPatra*)guys.spr(i))->clk5 == -16)
16754 {
16755 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16756 sfx(wpnsfx(wpn),pan(int32_t(x)));
16757 int32_t m=Ewpns.Count()-1;
16758 weapon *ew = (weapon*)(Ewpns.spr(m));
16759
16760 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16761 }
16762 break;
16763 }
16764 case 2: //one after another
16765 {
16766 if (dofire)
16767 {
16768 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16769 clk5 = -48 - (12*flycnt2);
16770 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16771 }
16772 if (((esPatra*)guys.spr(i))->clk5 == -16)
16773 {
16774 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16775 sfx(wpnsfx(wpn),pan(int32_t(x)));
16776 }
16777 break;
16778 }
16779 case 1: //random one eye
16780 {
16781 if (dofire && i == randeye)
16782 {
16783 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16784 {
16785 ((esPatra*)guys.spr(i))->clk5 = -48;
16786 clk5 = -48;
16787 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16788 }
16789 else
16790 {
16791 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16792 sfx(wpnsfx(wpn),pan(int32_t(x)));
16793 ((esPatra*)guys.spr(i))->clk5 = 0;
16794 clk5 = 0;
16795 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16796 }
16797 }
16798 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16799 {
16800 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16801 sfx(wpnsfx(wpn),pan(int32_t(x)));
16802 }
16803 break;
16804 }
16805 default: //old behavior, all eyes can fire any time
16806 {
16807
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16808
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16809
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16810 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16811 {
16812
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16813 {
16814 ((esPatra*)guys.spr(i))->clk5 = -48;
16815 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16816 }
16817 else
16818 {
16819 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16820 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
16821 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16822
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16823 }
16824 1155 }
16825
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16826 {
16827 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16828 sfx(wpnsfx(wpn),pan(int32_t(x)));
16829 }
16830 145268 break;
16831 }
16832 }
16833 145268 }
16834 145268 }
16835
16836 }
16837 334429 }
16838 46240 }
16839
16840 160441 adjusted=true;
16841 160441 return enemy::animate(index);
16842 161885 }
16843
16844 249 void ePatra::FirePatraWeapon()
16845 { //.707
16846 249 int32_t xoff = 0;
16847 249 int32_t yoff = 0;
16848
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16849 {
16850 xoff += (hit_width/2)-8;
16851 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16852 }
16853
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16854 {
16855 yoff += (hit_height/2)-8;
16856 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16857 }
16858 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16859
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16860 {
16861 case patrat8SHOT: //Fire Wizzrobe
16862 case patrat4SHOTDIAG:
16863 case patrat4SHOTRAND:
16864 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16865 {
16866 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16867 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16868 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16869 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16870
16871 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16872 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16873 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16874 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16875
16876 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16877 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16879 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16880
16881 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16882 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16883 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16884 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16885
16886 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16887 }
16888
16889 [[fallthrough]];
16890 case patrat4SHOTCARD: //Stalfos 3
16891 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16892 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16893 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16894 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16895 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16896 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16897 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16898 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16899 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16900 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16901 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16902 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16903 break;
16904
16905 default:
16906 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16907
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16908 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16909
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16910
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16911 {
16912 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16913 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16914 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16915 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16916 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16917 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16918 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16919 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16920 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16921 {
16922 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16923 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16924 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16925 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16926 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16927 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16928 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16929 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16930 }
16931 }
16932 249 break;
16933
16934 }
16935 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16936 //+0.46364761
16937 //11.80
16938 249 }
16939
16940 324242 void ePatra::draw(BITMAP *dest)
16941 {
16942 324242 tile=o_tile;
16943 324242 update_enemy_frame();
16944 324242 enemy::draw(dest);
16945 324242 }
16946
16947 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16948 {
16949 int32_t ret = enemy::defend(wpnId, power, edef);
16950
16951 if(ret < 0 && (flycnt||flycnt2))
16952 return 0;
16953
16954 return ret;
16955 }
16956
16957 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16958 {
16959 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16960
16961
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16962 1281 return 0;
16963
16964 452 return ret;
16965 1733 }
16966
16967 3312 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16968 1656 {
16969 //cs=8;
16970 1656 item_set=0;
16971 1656 misc=clk;
16972 1656 clk4 = 0;
16973 1656 clk5 = 0;
16974 1656 clk = -((misc*21)>>1)-1;
16975
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16976 1656 hit_width=12;
16977 1656 hit_height=12;
16978 1656 hxofs=2;
16979 1656 hyofs=2;
16980 1656 extend = 0;
16981 1656 txsz = 1;
16982 1656 tysz = 1;
16983 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16984 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16985 int32_t prntSIZEflags = prntenemy->SIZEflags;
16986 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16987 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16988 // al_trace("Enemy txsz:%i\n", txsz);
16989 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16990 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16991 else
16992 hxsz=12;
16993 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16994 else
16995 hysz=12;
16996 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16997 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16998 else
16999 hxofs=2;
17000 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17001 else hyofs=2;
17002 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17003 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17004 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17005 {
17006 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17007 }
17008
17009 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
17010 */
17011 1656 mainguy=count_enemy=false;
17012 1656 bgsfx=-1;
17013 //o_tile=0;
17014 1656 flags &= (~guy_neverret);
17015 1656 deadsfx = WAV_EDEAD;
17016 1656 hitsfx = WAV_EHIT;
17017 1656 isCore = false;
17018 1656 }
17019
17020 1010584 bool esPatra::animate(int32_t index)
17021 {
17022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
17023
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
17024 15160 return Dead(index);
17025
17026 995424 return enemy::animate(index);
17027 1010584 }
17028
17029 2028196 void esPatra::draw(BITMAP *dest)
17030 {
17031
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
17032 {
17033 1721294 tile = o_tile+(clk&3);
17034
17035
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
17036 {
17037 case up: //u
17038 214278 flip=0;
17039 214278 break;
17040
17041 case down: //d
17042 217924 flip=0;
17043 217924 tile+=4;
17044 217924 break;
17045
17046 case left: //l
17047 215346 flip=0;
17048 215346 tile+=8;
17049 215346 break;
17050
17051 case right: //r
17052 215726 flip=0;
17053 215726 tile+=12;
17054 215726 break;
17055
17056 case l_up: //ul
17057 213062 flip=0;
17058 213062 tile+=20;
17059 213062 break;
17060
17061 case r_up: //ur
17062 214350 flip=0;
17063 214350 tile+=24;
17064 214350 break;
17065
17066 case l_down: //dl
17067 215734 flip=0;
17068 215734 tile+=28;
17069 215734 break;
17070
17071 case r_down: //dr
17072 214874 flip=0;
17073 214874 tile+=32;
17074 214874 break;
17075 }
17076 1721294 }
17077 else
17078 {
17079 306902 tile = o_tile+((clk&2)>>1);
17080 }
17081
17082
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
17083 1913340 enemy::draw(dest);
17084 2028196 }
17085
17086
17087 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
17088 102 {
17089 102 adjusted=false;
17090
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
17091
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
17092 102 clk4 = 0;
17093 102 clk5 = 0;
17094 //flycnt=6; flycnt2=0;
17095 102 flycnt=dmisc1;
17096 102 flycnt2=0; // PatraBS doesn't have inner rings!
17097 102 loopcnt=0;
17098
17099 102 SIZEflags = d->SIZEflags;
17100
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17101 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17102 // al_trace("Enemy txsz:%i\n", txsz);
17103
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
17105 102 else hit_width = 32;
17106
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
17107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17109 102 else hxofs=-8;
17110
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17111 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
17113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17114 {
17115 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17116 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
17117 }
17118
17119
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
17120
17121
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
17122
17123 //nets+4480;
17124 102 }
17125
17126 35963 bool ePatraBS::animate(int32_t index)
17127 {
17128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
17129
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
17130 240 return Dead(index);
17131
17132
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
17133 {
17134 4018 removearmos(x,y,ffcactivated);
17135 4018 }
17136
17137 35723 variable_walk_8(rate,homing,hrate,spw_floater);
17138
17139
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
17140 {
17141 336 clk2=0;
17142
17143
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
17144 177 --loopcnt;
17145 else
17146 {
17147
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
17148 84 loopcnt=dmisc7;
17149 }
17150
17151 336 ++misc;
17152 336 }
17153
17154 // double size=1;;
17155
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
17156 {
17157
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
17158 {
17159 612 ((enemy*)guys.spr(i))->hp=dmisc3;
17160
17161
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
17162 {
17163 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
17164 612 }
17165 else
17166 {
17167 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
17168 }
17169
17170 612 ((enemy*)guys.spr(i))->cs = dmisc9;
17171 612 }
17172
17173
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
17174 {
17175
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
17176 {
17177 131 guys.swap(j,j+1);
17178 131 }
17179
17180 104 --flycnt;
17181 104 }
17182 else
17183 {
17184 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
17185
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
17186 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
17187 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
17188
17189
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
17190 {
17191 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
17192
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
17193 77643 }
17194 else
17195 {
17196 75725 guys.spr(i)->x = temp_x;
17197 75725 guys.spr(i)->y = temp_y;
17198 }
17199
17200 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17201 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
17202
17203
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17204 {
17205 18812 guys.spr(i)->dir=l_down;
17206 18812 }
17207
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17208 {
17209 18839 guys.spr(i)->dir=left;
17210 18839 }
17211
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17212 {
17213 18802 guys.spr(i)->dir=l_up;
17214 18802 }
17215
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17216 {
17217 20143 guys.spr(i)->dir=up;
17218 20143 }
17219
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17220 {
17221 18517 guys.spr(i)->dir=r_up;
17222 18517 }
17223
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17224 {
17225 18779 guys.spr(i)->dir=right;
17226 18779 }
17227
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17228 {
17229 18992 guys.spr(i)->dir=r_down;
17230 18992 }
17231 else
17232 {
17233 20484 guys.spr(i)->dir=down;
17234 }
17235
17236 153368 guys.spr(i)->x += x;
17237 153368 guys.spr(i)->y += y;
17238 }
17239 153472 }
17240
17241 35723 adjusted=true;
17242 35723 return enemy::animate(index);
17243 35963 }
17244
17245 72874 void ePatraBS::draw(BITMAP *dest)
17246 {
17247 72874 tile=o_tile;
17248
17249
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
17250 {
17251 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17252 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
17253
17254
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17255 {
17256 19146 lookat=l_down;
17257 19146 }
17258
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17259 {
17260 18298 lookat=down;
17261 18298 }
17262
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17263 {
17264 13624 lookat=r_down;
17265 13624 }
17266
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17267 {
17268 7492 lookat=right;
17269 7492 }
17270
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17271 {
17272 1170 lookat=r_up;
17273 1170 }
17274
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17275 {
17276 964 lookat=up;
17277 964 }
17278
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17279 {
17280 1700 lookat=l_up;
17281 1700 }
17282 else
17283 {
17284 10480 lookat=left;
17285 }
17286
17287
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
17288 {
17289 case up: //u
17290 964 flip=0;
17291 964 break;
17292
17293 case down: //d
17294 18298 flip=0;
17295 18298 tile+=8;
17296 18298 break;
17297
17298 case left: //l
17299 10480 flip=0;
17300 10480 tile+=40;
17301 10480 break;
17302
17303 case right: //r
17304 7492 flip=0;
17305 7492 tile+=48;
17306 7492 break;
17307
17308 case l_up: //ul
17309 1700 flip=0;
17310 1700 tile+=80;
17311 1700 break;
17312
17313 case r_up: //ur
17314 1170 flip=0;
17315 1170 tile+=88;
17316 1170 break;
17317
17318 case l_down: //dl
17319 19146 flip=0;
17320 19146 tile+=120;
17321 19146 break;
17322
17323 case r_down: //dr
17324 13624 flip=0;
17325 13624 tile+=128;
17326 13624 break;
17327 }
17328
17329 72874 tile+=(2*(clk&3));
17330 72874 xofs-=8;
17331 72874 yofs-=8;
17332 72874 drawblock(dest,15);
17333 72874 xofs+=8;
17334 72874 yofs+=8;
17335 72874 }
17336 else
17337 {
17338 flip=(clk&1);
17339 xofs-=8;
17340 yofs-=8;
17341 enemy::draw(dest);
17342 xofs+=16;
17343 enemy::draw(dest);
17344 yofs+=16;
17345 enemy::draw(dest);
17346 xofs-=16;
17347 enemy::draw(dest);
17348 xofs+=8;
17349 yofs-=8;
17350 }
17351 72874 }
17352
17353 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
17354 {
17355 int32_t ret = enemy::defend(wpnId, power, edef);
17356
17357 if(ret < 0 && (flycnt||flycnt2))
17358 return 0;
17359
17360 return ret;
17361 }
17362
17363 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
17364 {
17365 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
17366
17367
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
17368 81 return 0;
17369
17370 61 return ret;
17371 142 }
17372
17373 1224 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17374 612 {
17375 //cs=csBOSS;
17376 612 item_set=0;
17377 612 misc=clk;
17378 612 clk = -((misc*21)>>1)-1;
17379 612 clk4 = 0;
17380 612 clk5 = 0;
17381
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
17382 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
17383
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17384 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17385 // al_trace("Enemy txsz:%i\n", txsz);
17386
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
17387
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
17388 612 else hit_width=16;
17389
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
17390 612 else hit_height=16;
17391
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
17392
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
17393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17394 612 else hyofs=2;
17395 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17396
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17398 {
17399 yofs = (int32_t)prntenemy->yofs;
17400 }
17401
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17402
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
17403
17404 612 bgsfx=-1;
17405 612 mainguy=count_enemy=false;
17406 612 deadsfx = WAV_EDEAD;
17407 612 hitsfx = WAV_EHIT;
17408 612 flags &= ~guy_neverret;
17409 612 isCore = false;
17410 612 }
17411
17412 155090 bool esPatraBS::animate(int32_t index)
17413 {
17414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
17415
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
17416 1552 return Dead(index);
17417
17418 153538 return enemy::animate(index);
17419 155090 }
17420
17421 315868 void esPatraBS::draw(BITMAP *dest)
17422 {
17423 315868 tile=o_tile;
17424
17425
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
17426 {
17427
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
17428 {
17429 case up: //u
17430 41612 flip=0;
17431 41612 break;
17432
17433 case down: //d
17434 42622 flip=0;
17435 42622 tile+=4;
17436 42622 break;
17437
17438 case left: //l
17439 37916 flip=0;
17440 37916 tile+=8;
17441 37916 break;
17442
17443 case right: //r
17444 38458 flip=0;
17445 38458 tile+=12;
17446 38458 break;
17447
17448 case l_up: //ul
17449 38564 flip=0;
17450 38564 tile+=20;
17451 38564 break;
17452
17453 case r_up: //ur
17454 38568 flip=0;
17455 38568 tile+=24;
17456 38568 break;
17457
17458 case l_down: //dl
17459 38662 flip=0;
17460 38662 tile+=28;
17461 38662 break;
17462
17463 case r_down: //dr
17464 39466 flip=0;
17465 39466 tile+=32;
17466 39466 break;
17467 }
17468
17469 315868 tile += ((clk&6)>>1);
17470 315868 }
17471 else
17472 {
17473 tile += (clk&4)?1:0;
17474 }
17475
17476
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
17477 283752 enemy::draw(dest);
17478 315868 }
17479
17480
17481 /**********************************/
17482 /********** Misc Code ***********/
17483 /**********************************/
17484
17485 241616 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17486 {
17487
4/6
✓ Branch 0 taken 135636 times.
✓ Branch 1 taken 105980 times.
✓ Branch 2 taken 135636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135636 times.
✗ Branch 5 not taken.
241616 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17488
4/8
✓ Branch 0 taken 241616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241616 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241616 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241616 times.
✗ Branch 7 not taken.
241616 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17489
1/2
✓ Branch 0 taken 241616 times.
✗ Branch 1 not taken.
241616 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17490 241616 }
17491
17492 74280 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17493 {
17494 // Kludge
17495
4/8
✓ Branch 0 taken 74280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74280 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74280 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74280 times.
✗ Branch 7 not taken.
74280 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17496 74280 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74280 times.
74280 delete w;
17498 74280 return ret;
17499 }
17500
17501 9126 void enemy_scored(int32_t index)
17502 {
17503 9126 ((enemy*)guys.spr(index))->scored=true;
17504 9126 }
17505
17506 2179 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17507 {
17508
6/10
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2179 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 272 times.
✓ Branch 7 taken 1907 times.
✓ Branch 8 taken 2179 times.
✗ Branch 9 not taken.
2179 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17509
5/6
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1265 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2179 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17510 {
17511 4 g->o_tile = parentscr->guytile;
17512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
17513 4 g->flags &= ~guy_invisible;
17514 4 g->cs = parentscr->guycs;
17515 4 }
17516 2179 guys.add(g);
17517 2179 }
17518
17519 23564 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17520 {
17521
4/8
✓ Branch 0 taken 23564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23564 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23564 times.
✗ Branch 7 not taken.
23564 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17522 23564 items.add(i);
17523 23564 }
17524
17525 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17526 {
17527
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17528 150 items.add(i);
17529 150 }
17530
17531 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17532 {
17533
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17534 3 items.add(i);
17535 3 }
17536
17537 96 void kill_em_all()
17538 {
17539
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
17540 {
17541 353 enemy *e = ((enemy*)guys.spr(i));
17542
17543
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17544
17545 323 e->kickbucket();
17546 323 }
17547 96 }
17548
17549 bool can_kill_em_all()
17550 {
17551 for(int32_t i=0; i<guys.Count(); i++)
17552 {
17553 enemy *e = ((enemy*)guys.spr(i));
17554
17555 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17556 if(e->superman) continue;
17557 return true;
17558 }
17559 return false;
17560 }
17561
17562 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17563 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17564 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17565 {
17566 for(int32_t i=0; i<guys.Count(); i++)
17567 {
17568 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17569 {
17570 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17571 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17572 {
17573 return i;
17574 }
17575 }
17576 }
17577
17578 return -1;
17579 }
17580
17581 13020163 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17582 {
17583
4/4
✓ Branch 0 taken 16489 times.
✓ Branch 1 taken 13003674 times.
✓ Branch 2 taken 33603022 times.
✓ Branch 3 taken 12989511 times.
46592533 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17584 {
17585
2/2
✓ Branch 0 taken 30652 times.
✓ Branch 1 taken 33572370 times.
33603022 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17586 {
17587 30652 return i;
17588 }
17589 33572370 }
17590
17591 12989511 return -1;
17592 13020163 }
17593
17594 // For Hero's hit detection. Count them if they are dying.
17595 52156 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17596 {
17597 52156 enemy *e = (enemy*)guys.spr(index);
17598
3/4
✓ Branch 0 taken 52156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27788 times.
✓ Branch 3 taken 24368 times.
52156 if(!e || e->hp > 0)
17599 27788 return -1;
17600
17601 24368 bool d = e->dying;
17602 24368 int32_t hc = e->hclk;
17603 24368 e->dying = false;
17604 24368 e->hclk = 0;
17605 24368 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17606 24368 e->dying = d;
17607 24368 e->hclk = hc;
17608
17609
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24211 times.
24368 return hit ? index : -1;
17610 52156 }
17611
17612 14179535 bool hasMainGuy()
17613 {
17614
2/2
✓ Branch 0 taken 15388343 times.
✓ Branch 1 taken 5545996 times.
20934339 for(int32_t i=0; i<guys.Count(); i++)
17615 {
17616
2/2
✓ Branch 0 taken 8633539 times.
✓ Branch 1 taken 6754804 times.
15388343 if(((enemy*)guys.spr(i))->mainguy)
17617 {
17618 8633539 return true;
17619 }
17620 6754804 }
17621
17622 5545996 return false;
17623 14179535 }
17624
17625 138 void EatHero(int32_t index)
17626 {
17627 138 ((eStalfos*)guys.spr(index))->eathero();
17628 138 }
17629
17630 9 void GrabHero(int32_t index)
17631 {
17632 9 ((eWallM*)guys.spr(index))->grabhero();
17633 9 }
17634
17635 1338 bool CarryHero()
17636 {
17637
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
17638 {
17639
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17640 {
17641
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
17642 {
17643 1338 Hero.x=guys.spr(i)->x;
17644 1338 Hero.y=guys.spr(i)->y;
17645 1338 return ((eWallM*)guys.spr(i))->misc > 0;
17646 }
17647 505 }
17648
17649 // Like Likes currently can't carry Hero.
17650 /*
17651 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17652 {
17653 if(((eLikeLike*)guys.spr(i))->hashero)
17654 {
17655 Hero.x=guys.spr(i)->x;
17656 Hero.y=guys.spr(i)->y;
17657 return (true);
17658 }
17659 }*/
17660 2595 }
17661
17662 return false;
17663 1338 }
17664
17665 // Move item with guy
17666 void movefairy(zfix &x,zfix &y,int32_t misc)
17667 {
17668 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17669
17670 if(i!=-1)
17671 {
17672 x = guys.spr(i)->x;
17673 y = guys.spr(i)->y;
17674 }
17675 }
17676
17677 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17678 void movefairy2(zfix x,zfix y,int32_t misc)
17679 {
17680 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17681
17682 if(i!=-1)
17683 {
17684 guys.spr(i)->x = x;
17685 guys.spr(i)->y = y;
17686 }
17687 }// Move item with guy
17688
17689 60438 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17690 {
17691 60438 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17692
17693
1/2
✓ Branch 0 taken 60438 times.
✗ Branch 1 not taken.
60438 if(fairy)
17694 {
17695 60438 x = fairy->x;
17696 60438 y = fairy->y;
17697 60438 }
17698 60438 }
17699
17700 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17701 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17702 {
17703 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17704
17705
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
17706 {
17707 404 fairy->x = x;
17708 404 fairy->y = y;
17709 404 }
17710 404 }
17711
17712 void killfairy(int32_t misc)
17713 {
17714 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17715 guys.del(i);
17716 }
17717
17718 217 int32_t getGuyIndex(const int32_t eid)
17719 {
17720
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 for(word i = 0; i < guys.Count(); i++)
17721 {
17722
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 609 times.
826 if(guys.spr(i)->getUID() == eid)
17723 217 return i;
17724 609 }
17725
17726 return -1;
17727 217 }
17728
17729 217 void killfairynew(item const &itemfairy)
17730 {
17731 217 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17732
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17733 217 }
17734
17735 //Should probably change this to return an 'enemy*', null on failure -Em
17736 21694 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17737 {
17738 21694 return addenemy(x,y,0,id,clk);
17739 }
17740
17741 1965 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17742 {
17743 1965 return addchild(x,y,0,id,clk, parent_scriptUID);
17744 }
17745
17746 1997 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17747 {
17748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
17749
17750 1997 int32_t ret = 0;
17751 1997 sprite *e=NULL;
17752 1997 al_trace("Adding child\n");
17753
17754
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17755 {
17756 //Fixme: possible enemy memory leak. (minor)
17757 case eeWALK:
17758
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17759 110 break;
17760
17761 case eeLEV:
17762 e = new eLeever((zfix)x,(zfix)y,id,clk);
17763 break;
17764
17765 case eeTEK:
17766 e = new eTektite((zfix)x,(zfix)y,id,clk);
17767 break;
17768
17769 case eePEAHAT:
17770 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17771 break;
17772
17773 case eeZORA:
17774 e = new eZora((zfix)x,(zfix)y,id,clk);
17775 break;
17776
17777 case eeGHINI:
17778 e = new eGhini((zfix)x,(zfix)y,id,clk);
17779 break;
17780
17781 case eeKEESE:
17782
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17783 1865 break;
17784
17785 case eeWIZZ:
17786
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17787 15 break;
17788
17789 case eePROJECTILE:
17790 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17791 break;
17792
17793 case eeWALLM:
17794 e = new eWallM((zfix)x,(zfix)y,id,clk);
17795 break;
17796
17797 case eeAQUA:
17798 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17799 break;
17800
17801 case eeMOLD:
17802 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17803 break;
17804
17805 case eeMANHAN:
17806
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17807 1 break;
17808
17809 case eeGLEEOK:
17810 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17811 break;
17812
17813 case eeGHOMA:
17814 e = new eGohma((zfix)x,(zfix)y,id,clk);
17815 break;
17816
17817 case eeLANM:
17818 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
17819 break;
17820
17821 case eeGANON:
17822 e = new eGanon((zfix)x,(zfix)y,id,clk);
17823 break;
17824
17825 case eeFAIRY:
17826 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17827 break;
17828
17829 case eeFIRE:
17830
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17831 2 break;
17832
17833 case eeOTHER:
17834 e = new eOther((zfix)x,(zfix)y,id,clk);
17835 break;
17836
17837
17838 case eeSCRIPT01:
17839 case eeSCRIPT02:
17840 case eeSCRIPT03:
17841 case eeSCRIPT04:
17842 case eeSCRIPT05:
17843 case eeSCRIPT06:
17844 case eeSCRIPT07:
17845 case eeSCRIPT08:
17846 case eeSCRIPT09:
17847 case eeSCRIPT10:
17848 case eeSCRIPT11:
17849 case eeSCRIPT12:
17850 case eeSCRIPT13:
17851 case eeSCRIPT14:
17852 case eeSCRIPT15:
17853 case eeSCRIPT16:
17854 case eeSCRIPT17:
17855 case eeSCRIPT18:
17856 case eeSCRIPT19:
17857 case eeSCRIPT20:
17858 {
17859 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17860 {
17861 e = new eScript((zfix)x,(zfix)y,id,clk);
17862 break;
17863 }
17864 else return 0;
17865 }
17866
17867 case eeFFRIENDLY01:
17868 case eeFFRIENDLY02:
17869 case eeFFRIENDLY03:
17870 case eeFFRIENDLY04:
17871 case eeFFRIENDLY05:
17872 case eeFFRIENDLY06:
17873 case eeFFRIENDLY07:
17874 case eeFFRIENDLY08:
17875 case eeFFRIENDLY09:
17876 case eeFFRIENDLY10:
17877 {
17878 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17879 {
17880 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17881 }
17882 else return 0;
17883
17884 }
17885
17886 case eeSPINTILE:
17887 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17888 break;
17889
17890 // and these enemies use the misc10/misc2 value
17891 case eeROCK:
17892 {
17893 switch(guysbuf[id&0xFFF].misc10)
17894 {
17895 case 1:
17896 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17897 break;
17898
17899 case 0:
17900 default:
17901 e = new eRock((zfix)x,(zfix)y,id,clk);
17902 break;
17903 }
17904
17905 break;
17906 }
17907
17908 case eeTRAP:
17909 {
17910 switch(guysbuf[id&0xFFF].misc2)
17911 {
17912 case 1:
17913 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17914 break;
17915
17916 case 0:
17917 default:
17918 e = new eTrap((zfix)x,(zfix)y,id,clk);
17919 break;
17920 }
17921
17922 break;
17923 }
17924
17925 case eeDONGO:
17926 {
17927 switch(guysbuf[id&0xFFF].misc10)
17928 {
17929 case 1:
17930 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17931 break;
17932
17933 case 0:
17934 default:
17935 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17936 break;
17937 }
17938
17939 break;
17940 }
17941
17942 case eeDIG:
17943 {
17944
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
17945 {
17946 case 1:
17947 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17948 break;
17949
17950 4 case 0:
17951 default:
17952
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17953 4 break;
17954 }
17955
17956 4 break;
17957 }
17958
17959 case eePATRA:
17960 {
17961 switch(guysbuf[id&0xFFF].misc10)
17962 {
17963 case 1:
17964 if (get_qr(qr_HARDCODED_BS_PATRA))
17965 {
17966 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17967 break;
17968 }
17969 [[fallthrough]];
17970 case 0:
17971 default:
17972 e = new ePatra((zfix)x,(zfix)y,id,clk);
17973 break;
17974 }
17975
17976 break;
17977 }
17978
17979 case eeGUY:
17980 {
17981 switch(guysbuf[id&0xFFF].misc10)
17982 {
17983 case 1:
17984 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17985 break;
17986
17987 case 0:
17988 default:
17989 e = new eNPC((zfix)x,(zfix)y,id,clk);
17990 break;
17991 }
17992
17993 break;
17994 }
17995
17996 case eeNONE:
17997 if(guysbuf[id&0xFFF].misc10 ==1)
17998 {
17999 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18000 break;
18001 break;
18002 }
18003 [[fallthrough]];
18004 default:
18005
18006 return 0;
18007 }
18008
18009 1997 ret++; // Made one enemy.
18010
18011
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
18012 {
18013 7 e->z = (zfix)z;
18014 7 }
18015
18016
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
18017 1997 ((enemy*)e)->parent_script_UID = parent_scriptUID;
18018 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
18019 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
18020 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18021 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18022
18023
18024
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
18025 {
18026 return 0;
18027 }
18028
18029 // add segments of segmented enemies
18030 1997 int32_t c=0;
18031
18032
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
18033 {
18034 case eeMOLD:
18035 {
18036 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18037 id &= 0xFFF;
18038
18039 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18040 {
18041 //christ this is messy -DD
18042 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18043
18044 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18045 {
18046 al_trace("Moldorm segment %d could not be created!\n",i+1);
18047
18048 for(int32_t j=0; j<i+1; j++)
18049 guys.del(guys.Count()-1);
18050
18051 return 0;
18052 }
18053
18054 if(i>0)
18055 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18056
18057 ret++;
18058 }
18059
18060 break;
18061 }
18062
18063 case eeLANM:
18064 {
18065 id &= 0xFFF;
18066 int32_t shft = guysbuf[id].misc2;
18067 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18068
18069 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18070 {
18071 al_trace("Lanmola segment 1 could not be created!\n");
18072 guys.del(guys.Count()-1);
18073 return 0;
18074 }
18075
18076 ret++;
18077
18078 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18079 {
18080 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18081 {
18082 al_trace("Lanmola segment %d could not be created!\n",i+1);
18083
18084 for(int32_t j=0; j<i+1; j++)
18085 guys.del(guys.Count()-1);
18086
18087 return 0;
18088 }
18089
18090 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18091 ret++;
18092 }
18093 }
18094 break;
18095
18096 case eeMANHAN:
18097 1 id &= 0xFFF;
18098
18099
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18100 {
18101
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18102 {
18103 al_trace("Manhandla head %d could not be created!\n",i+1);
18104
18105 for(int32_t j=0; j<i+1; j++)
18106 {
18107 guys.del(guys.Count()-1);
18108 }
18109
18110 return 0;
18111 }
18112
18113 4 ret++;
18114 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18115 4 }
18116
18117 1 break;
18118
18119 case eeGLEEOK:
18120 {
18121 id &= 0xFFF;
18122
18123 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18124 {
18125 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
18126 {
18127 al_trace("Gleeok head %d could not be created!\n",i+1);
18128
18129 for(int32_t j=0; j<i+1; j++)
18130 {
18131 guys.del(guys.Count()-1);
18132 }
18133
18134 return false;
18135 }
18136
18137 c-=guysbuf[id].misc4;
18138 ret++;
18139 }
18140 }
18141 break;
18142
18143
18144 case eePATRA:
18145 {
18146 id &= 0xFFF;
18147 int32_t outeyes = 0;
18148
18149 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18150 {
18151 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18152 {
18153 al_trace("Patra outer eye %d could not be created!\n",i+1);
18154
18155 for(int32_t j=0; j<i+1; j++)
18156 guys.del(guys.Count()-1);
18157
18158 return 0;
18159 }
18160 else
18161 outeyes++;
18162
18163 ret++;
18164 }
18165
18166 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18167 {
18168 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18169 {
18170 al_trace("Patra inner eye %d could not be created!\n",i+1);
18171
18172 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18173 guys.del(guys.Count()-1);
18174
18175 return 0;
18176 }
18177
18178 ret++;
18179 }
18180
18181 break;
18182 }
18183 }
18184
18185 1997 return ret;
18186 1997 }
18187
18188 // Returns number of enemies/segments created
18189 101419 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
18190 {
18191 //zprint2("addenemy id is: %d\n", (id&0xFFF));
18192 101419 int32_t realid = id&0xFFF;
18193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101419 times.
101419 if( realid > MAXGUYS )
18194 {
18195 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
18196 return 0;
18197 }
18198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101419 times.
101419 if(id <= 0) return 0;
18199
18200 101419 int32_t ret = 0;
18201 101419 sprite *e=NULL;
18202
18203
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50006 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5196 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2765 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11717 times.
✓ Branch 10 taken 5311 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 730 times.
✓ Branch 21 taken 761 times.
✓ Branch 22 taken 7297 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2432 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
101419 switch(guysbuf[id&0xFFF].family)
18204 {
18205 //Fixme: possible enemy memory leak. (minor)
18206 case eeWALK:
18207
3/6
✓ Branch 0 taken 50006 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50006 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50006 times.
✗ Branch 5 not taken.
50006 e = new eStalfos((zfix)x,(zfix)y,id,clk);
18208 50006 break;
18209
18210 case eeLEV:
18211
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
18212 3942 break;
18213
18214 case eeTEK:
18215
3/6
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5196 times.
✗ Branch 5 not taken.
5196 e = new eTektite((zfix)x,(zfix)y,id,clk);
18216 5196 break;
18217
18218 case eePEAHAT:
18219
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
18220 1825 break;
18221
18222 case eeZORA:
18223
3/6
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2765 times.
✗ Branch 5 not taken.
2765 e = new eZora((zfix)x,(zfix)y,id,clk);
18224 2765 break;
18225
18226 case eeGHINI:
18227
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
18228 461 break;
18229
18230 case eeKEESE:
18231
3/6
✓ Branch 0 taken 11717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11717 times.
✗ Branch 5 not taken.
11717 e = new eKeese((zfix)x,(zfix)y,id,clk);
18232 11717 break;
18233
18234 case eeWIZZ:
18235
3/6
✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5311 times.
✗ Branch 5 not taken.
5311 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
18236 5311 break;
18237
18238 case eePROJECTILE:
18239
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
18240 4429 break;
18241
18242 case eeWALLM:
18243
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
18244 998 break;
18245
18246 case eeAQUA:
18247
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
18248 126 break;
18249
18250 case eeMOLD:
18251
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18252 618 break;
18253
18254 case eeMANHAN:
18255
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
18256 149 break;
18257
18258 case eeGLEEOK:
18259
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18260 168 break;
18261
18262 case eeGHOMA:
18263
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
18264 93 break;
18265
18266 case eeLANM:
18267
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
18268 420 break;
18269
18270 case eeGANON:
18271
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
18272 13 break;
18273
18274 case eeFAIRY:
18275
3/6
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 730 times.
✗ Branch 5 not taken.
730 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
18276 730 break;
18277
18278 case eeFIRE:
18279
3/6
✓ Branch 0 taken 761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 761 times.
✗ Branch 5 not taken.
761 e = new eFire((zfix)x,(zfix)y,id,clk);
18280 761 break;
18281
18282 case eeOTHER:
18283
3/6
✓ Branch 0 taken 7297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7297 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7297 times.
✗ Branch 5 not taken.
7297 e = new eOther((zfix)x,(zfix)y,id,clk);
18284 7297 break;
18285
18286
18287 case eeSCRIPT01:
18288 case eeSCRIPT02:
18289 case eeSCRIPT03:
18290 case eeSCRIPT04:
18291 case eeSCRIPT05:
18292 case eeSCRIPT06:
18293 case eeSCRIPT07:
18294 case eeSCRIPT08:
18295 case eeSCRIPT09:
18296 case eeSCRIPT10:
18297 case eeSCRIPT11:
18298 case eeSCRIPT12:
18299 case eeSCRIPT13:
18300 case eeSCRIPT14:
18301 case eeSCRIPT15:
18302 case eeSCRIPT16:
18303 case eeSCRIPT17:
18304 case eeSCRIPT18:
18305 case eeSCRIPT19:
18306 case eeSCRIPT20:
18307 {
18308 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18309 {
18310 e = new eScript((zfix)x,(zfix)y,id,clk);
18311 break;
18312 }
18313 else return 0;
18314 }
18315
18316 case eeFFRIENDLY01:
18317 case eeFFRIENDLY02:
18318 case eeFFRIENDLY03:
18319 case eeFFRIENDLY04:
18320 case eeFFRIENDLY05:
18321 case eeFFRIENDLY06:
18322 case eeFFRIENDLY07:
18323 case eeFFRIENDLY08:
18324 case eeFFRIENDLY09:
18325 case eeFFRIENDLY10:
18326 {
18327 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18328 {
18329 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
18330 }
18331 else return 0;
18332
18333 }
18334
18335 case eeSPINTILE:
18336
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
18337 94 break;
18338
18339 // and these enemies use the misc10/misc2 value
18340 case eeROCK:
18341 {
18342
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].misc10)
18343 {
18344 case 1:
18345
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
18346 30 break;
18347
18348 354 case 0:
18349 default:
18350
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
18351 354 break;
18352 }
18353
18354 384 break;
18355 }
18356
18357 case eeTRAP:
18358 {
18359
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1600 times.
2432 switch(guysbuf[id&0xFFF].misc2)
18360 {
18361 case 1:
18362
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
18363 832 break;
18364
18365 1600 case 0:
18366 default:
18367
3/6
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600 times.
✗ Branch 5 not taken.
1600 e = new eTrap((zfix)x,(zfix)y,id,clk);
18368 1600 break;
18369 }
18370
18371 2432 break;
18372 }
18373
18374 case eeDONGO:
18375 {
18376
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].misc10)
18377 {
18378 case 1:
18379
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
18380 48 break;
18381
18382 203 case 0:
18383 default:
18384
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
18385 203 break;
18386 }
18387
18388 251 break;
18389 }
18390
18391 case eeDIG:
18392 {
18393
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].misc10)
18394 {
18395 case 1:
18396
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
18397 327 break;
18398
18399 76 case 0:
18400 default:
18401
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
18402 76 break;
18403 }
18404
18405 403 break;
18406 }
18407
18408 case eePATRA:
18409 {
18410
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].misc10)
18411 {
18412 case 1:
18413
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
18414 {
18415
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
18416 102 break;
18417 }
18418 [[fallthrough]];
18419 190 case 0:
18420 default:
18421
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
18422 190 break;
18423 }
18424
18425 292 break;
18426 }
18427
18428 case eeGUY:
18429 {
18430
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].misc10)
18431 {
18432 case 1:
18433 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18434 break;
18435
18436 5 case 0:
18437 default:
18438
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
18439 5 break;
18440 }
18441
18442 5 break;
18443 }
18444
18445 case eeNONE:
18446
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].misc10 ==1)
18447 {
18448
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18449 533 break;
18450 break;
18451 }
18452 [[fallthrough]];
18453 default:
18454
18455 return 0;
18456 }
18457
18458 101419 ret++; // Made one enemy.
18459
18460
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 101288 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 106 times.
101419 if(z && canfall(id))
18461 {
18462 106 e->z = (zfix)z;
18463 106 }
18464
18465
2/2
✓ Branch 0 taken 101288 times.
✓ Branch 1 taken 131 times.
101419 ((enemy*)e)->ceiling = (z && canfall(id));
18466
18467
1/2
✓ Branch 0 taken 101419 times.
✗ Branch 1 not taken.
101419 if(!guys.add(e))
18468 {
18469 return 0;
18470 }
18471
18472 // add segments of segmented enemies
18473 101419 int32_t c=0;
18474
18475
6/6
✓ Branch 0 taken 99772 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
101419 switch(guysbuf[id&0xFFF].family)
18476 {
18477 case eeMOLD:
18478 {
18479 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18480 618 id &= 0xFFF;
18481
18482
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18483 {
18484 //christ this is messy -DD
18485 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18486
18487
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18488 {
18489 al_trace("Moldorm segment %d could not be created!\n",i+1);
18490
18491 for(int32_t j=0; j<i+1; j++)
18492 guys.del(guys.Count()-1);
18493
18494 return 0;
18495 }
18496
18497
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
18498 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18499
18500 3150 ret++;
18501 3150 }
18502
18503 618 break;
18504 }
18505
18506 case eeLANM:
18507 {
18508 420 id &= 0xFFF;
18509 420 int32_t shft = guysbuf[id].misc2;
18510 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18511
18512
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18513 {
18514 al_trace("Lanmola segment 1 could not be created!\n");
18515 guys.del(guys.Count()-1);
18516 return 0;
18517 }
18518
18519 420 ret++;
18520
18521
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18522 {
18523
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18524 {
18525 al_trace("Lanmola segment %d could not be created!\n",i+1);
18526
18527 for(int32_t j=0; j<i+1; j++)
18528 guys.del(guys.Count()-1);
18529
18530 return 0;
18531 }
18532
18533 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18534 1847 ret++;
18535 1847 }
18536 }
18537 420 break;
18538
18539 case eeMANHAN:
18540 149 id &= 0xFFF;
18541
18542
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18543 {
18544
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18545 {
18546 al_trace("Manhandla head %d could not be created!\n",i+1);
18547
18548 for(int32_t j=0; j<i+1; j++)
18549 {
18550 guys.del(guys.Count()-1);
18551 }
18552
18553 return 0;
18554 }
18555
18556 688 ret++;
18557 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18558 688 }
18559
18560 149 break;
18561
18562 case eeGLEEOK:
18563 {
18564 168 id &= 0xFFF;
18565 168 eGleeok* parent = (eGleeok*)e;
18566
18567
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18568 {
18569
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18570
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
18571 {
18572 al_trace("Gleeok head %d could not be created!\n",i+1);
18573
18574 for(int32_t j=0; j<i+1; j++)
18575 {
18576 guys.del(guys.Count()-1);
18577 }
18578
18579 return false;
18580 }
18581
18582 533 head->necktile=parent->necktile;
18583 533 head->dummy_int[1]=parent->necktile;
18584
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
18585 {
18586 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18587 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18588 421 }
18589 else
18590 {
18591 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
18592 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
18593 }
18594 533 head->tile = head->dummy_int[2];
18595
18596 533 c-=guysbuf[id].misc4;
18597 533 ret++;
18598 533 }
18599 }
18600 168 break;
18601
18602
18603 case eePATRA:
18604 {
18605 292 id &= 0xFFF;
18606 292 int32_t outeyes = 0;
18607
18608
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18609 {
18610
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18611 {
18612 al_trace("Patra outer eye %d could not be created!\n",i+1);
18613
18614 for(int32_t j=0; j<i+1; j++)
18615 guys.del(guys.Count()-1);
18616
18617 return 0;
18618 }
18619 else
18620 1956 outeyes++;
18621
18622 1956 ret++;
18623 1956 }
18624
18625
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18626 {
18627
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18628 {
18629 al_trace("Patra inner eye %d could not be created!\n",i+1);
18630
18631 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18632 guys.del(guys.Count()-1);
18633
18634 return 0;
18635 }
18636
18637 312 ret++;
18638 312 }
18639
18640 292 break;
18641 }
18642 }
18643
18644 101419 return ret;
18645 101419 }
18646
18647 1847854 bool isjumper(int32_t id)
18648 {
18649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1847854 times.
1847854 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18650 {
18651 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
18652 return false;
18653 }
18654
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1743867 times.
✓ Branch 2 taken 103978 times.
1847854 switch(guysbuf[id&0xFFF].family)
18655 {
18656 case eeROCK:
18657 case eeTEK:
18658 9 return true;
18659
18660 case eeWALK:
18661
3/4
✓ Branch 0 taken 103978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 91713 times.
103978 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
18662 91713 }
18663
18664 1835580 return false;
18665 1847854 }
18666
18667
18668 291817 bool isfixedtogrid(int32_t id)
18669 {
18670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291817 times.
291817 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18671 {
18672 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
18673 return false;
18674 }
18675
1/2
✓ Branch 0 taken 291817 times.
✗ Branch 1 not taken.
291817 switch(guysbuf[id&0xFFF].family)
18676 {
18677 case eeWALK:
18678 case eeLEV:
18679 case eeZORA:
18680 case eeDONGO:
18681 case eeGANON:
18682 case eeROCK:
18683 case eeGLEEOK:
18684 case eeAQUA:
18685 case eeLANM:
18686 return true;
18687 }
18688
18689 291817 return false;
18690 291817 }
18691
18692 // Can't fall, can have Z value.
18693 51762590 bool isflier(int32_t id)
18694 {
18695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51762590 times.
51762590 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18696 {
18697 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
18698 return false;
18699 }
18700
2/2
✓ Branch 0 taken 45334224 times.
✓ Branch 1 taken 6428366 times.
51762590 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18701 {
18702 case eePEAHAT:
18703 case eeKEESE:
18704 case eePATRA:
18705 case eeFAIRY:
18706 case eeGHINI:
18707
18708 // Could theoretically have their Z set by a script
18709 case eeFIRE:
18710 6428366 return true;
18711 break;
18712 }
18713
18714 45334224 return false;
18715 51762590 }
18716
18717 // Can't have Z position
18718 3700639 bool never_in_air(int32_t id)
18719 {
18720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3700639 times.
3700639 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18721 {
18722 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
18723 return false;
18724 }
18725
2/2
✓ Branch 0 taken 3691089 times.
✓ Branch 1 taken 9550 times.
3700639 switch(guysbuf[id&0xFFF].family)
18726 {
18727 case eeMANHAN:
18728 case eeMOLD:
18729 case eeLANM:
18730 case eeGLEEOK:
18731 case eeZORA:
18732 case eeLEV:
18733 case eeAQUA:
18734 case eeROCK:
18735 case eeGANON:
18736 case eeTRAP:
18737 case eePROJECTILE:
18738 case eeSPINTILE:
18739 9550 return true;
18740 }
18741
18742 3691089 return false;
18743 3700639 }
18744
18745 2008615 bool canfall(int32_t id)
18746 {
18747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2008615 times.
2008615 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18748 {
18749 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
18750 return false;
18751 }
18752
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2008575 times.
✓ Branch 2 taken 40 times.
2008615 switch(guysbuf[id&0xFFF].family)
18753 {
18754 case eeGUY:
18755 {
18756
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
18757 40 return false;
18758
18759 switch(guysbuf[id&0xFFF].misc10)
18760 {
18761 case 1:
18762 case 2:
18763 return true;
18764
18765 case 0:
18766 case 3:
18767 default:
18768 return false;
18769 }
18770
18771 case eeGHOMA:
18772 case eeDIG:
18773 return false;
18774 }
18775 }
18776
18777
18778
4/4
✓ Branch 0 taken 2000139 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 152285 times.
✓ Branch 3 taken 1847854 times.
2008575 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18779 2008615 }
18780
18781 73638700 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18782 {
18783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73638700 times.
73638700 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18784 {
18785 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
18786 return false;
18787 }
18788 //Z_scripterrlog("canfall family is %d:\n", family);
18789 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
18790 //if ( family == eeFIRE && id >= eSTART )
18791 //{
18792 // Z_scripterrlog("eeFire\n");
18793 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
18794 //}
18795
18796 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18797
18798
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71142871 times.
✓ Branch 2 taken 2066894 times.
73638700 switch(guysbuf[id&0xFFF].family)
18799 {
18800 case eeGUY:
18801 {
18802
1/2
✓ Branch 0 taken 2066894 times.
✗ Branch 1 not taken.
2066894 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18803 2066894 return false;
18804
18805 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
18806 {
18807 case 1:
18808 case 2:
18809 return true;
18810
18811 case 0:
18812 case 3:
18813 default:
18814 return false;
18815 }
18816
18817 case eeGHOMA:
18818 case eeDIG:
18819 428935 return false;
18820 }
18821 }
18822
18823
2/2
✓ Branch 0 taken 38939893 times.
✓ Branch 1 taken 32202978 times.
71142871 if(!checkgrav) return true;
18824 38939893 return (moveflags & FLAG_OBEYS_GRAV);
18825
18826 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18827 // {
18828 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
18829 // else return false;
18830 // }
18831 // else
18832 // {
18833 // return (moveflags & FLAG_OBEYS_GRAV);
18834 // }
18835 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18836 73638700 }
18837
18838 1266 void addfires()
18839 {
18840
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 455 times.
1266 if(!get_qr(qr_NOGUYFIRES))
18841 {
18842 455 int32_t bs = get_qr(qr_BSZELDA);
18843 455 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18844 455 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18845 455 }
18846 1266 }
18847
18848 35259 void loadguys()
18849 {
18850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35259 times.
35259 if(loaded_guys)
18851 return;
18852
18853 35259 loaded_guys=true;
18854
18855 35259 byte Guy=0;
18856 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18857 // Else use mITEM and ipONETIME
18858 35259 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18859 35259 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18860
18861 35259 repaircharge=0;
18862 35259 adjustmagic=false;
18863 35259 learnslash=false;
18864
18865
2/2
✓ Branch 0 taken 105777 times.
✓ Branch 1 taken 35259 times.
141036 for(int32_t i=0; i<3; i++)
18866 {
18867 105777 prices[i]=0;
18868 105777 }
18869
18870 35259 hasitem=0;
18871
18872 35259 mapscr* guyscr = tmpscr;
18873
4/4
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 34355 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 429 times.
35259 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18874 {
18875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(DMaps[currdmap].flags&dmfCAVES)
18876 {
18877 429 Guy=tmpscr[1].guy;
18878 429 guyscr = tmpscr+1;
18879 429 }
18880 429 }
18881 else
18882 {
18883 34830 Guy=tmpscr->guy;
18884
18885
4/4
✓ Branch 0 taken 34355 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 24130 times.
✓ Branch 3 taken 10225 times.
34830 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18886 10225 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18887 }
18888
18889 35259 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18890 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18891
4/4
✓ Branch 0 taken 3845 times.
✓ Branch 1 taken 31414 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 1307 times.
35259 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18892 {
18893
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1295 times.
1307 if(tmpscr->room==rZELDA)
18894 {
18895 12 addguy(120,72,Guy,-15,true,guyscr);
18896 12 guys.spr(0)->hxofs=1000;
18897 12 addenemy(128,96,eFIRE,-15);
18898 12 addenemy(112,96,eFIRE,-15);
18899 12 addenemy(96,120,eFIRE,-15);
18900 12 addenemy(144,120,eFIRE,-15);
18901 12 return;
18902 }
18903
18904
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 4 times.
2586 bool ffire = oldguy
18905
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 25 times.
1291 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18906 4 : (guyscr->roomflags&RFL_GUYFIRES);
18907
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1266 times.
1295 if(ffire)
18908 1266 addfires();
18909
18910
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 423 times.
1295 if(currscr>=128)
18911
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
436 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18912 13 Guy=0;
18913
18914
4/6
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1083 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1295 switch(tmpscr->room)
18915 {
18916 case rSP_ITEM:
18917 case rGRUMBLE:
18918 case rBOMBS:
18919 case rARROWS:
18920 case rSWINDLE:
18921 case rMUPGRADE:
18922 case rLEARNSLASH:
18923 case rTAKEONE:
18924
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 41 times.
166 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18925 55 Guy=0;
18926
18927 166 break;
18928
18929 case rREPAIR:
18930 if (get_qr(qr_OLD_DOORREPAIR)) break;
18931 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18932 Guy=0;
18933
18934 break;
18935 case rRP_HC:
18936 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18937 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18938 Guy=0;
18939
18940 break;
18941 case rMONEY:
18942
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18943 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18944 Guy=0;
18945
18946 break;
18947
18948 case rTRIFORCE:
18949 {
18950 45 int32_t tc = TriforceCount();
18951
18952
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18953 {
18954
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18955 10 Guy=0;
18956 9 }
18957 else
18958 {
18959
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18960 33 Guy=0;
18961 }
18962 }
18963 43 break;
18964 }
18965
18966
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1186 times.
1293 if(Guy)
18967 {
18968
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1157 times.
1186 if(ffire)
18969 1157 blockpath=true;
18970
18971
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 776 times.
1186 if(currscr<128)
18972 776 sfx(WAV_SCALE);
18973
18974
4/4
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 727 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 355 times.
1186 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18975 1186 Hero.Freeze();
18976 1186 }
18977 1293 }
18978
5/6
✓ Branch 0 taken 32163 times.
✓ Branch 1 taken 1789 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32092 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1789 times.
33952 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18979 {
18980 71 sfx(WAV_SCALE);
18981 71 addguy(120,62,Guy,-14,false,guyscr);
18982 71 }
18983
18984 35245 loaditem();
18985
18986 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18987 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18988
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 35226 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
35245 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18989 {
18990 //setmapflag();
18991
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18992 150 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18993 15 }
18994 35257 }
18995
18996 35264 void loaditem()
18997 {
18998 35264 byte Item = 0;
18999
19000
2/2
✓ Branch 0 taken 34360 times.
✓ Branch 1 taken 904 times.
35264 if(currscr<128)
19001 {
19002 34360 Item=tmpscr->item;
19003
19004
4/4
✓ Branch 0 taken 1580 times.
✓ Branch 1 taken 32780 times.
✓ Branch 2 taken 31333 times.
✓ Branch 3 taken 3027 times.
34360 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
19005 {
19006
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2968 times.
3027 if(tmpscr->flags8&fSECRETITEM)
19007 59 hasitem=8;
19008
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 1811 times.
2968 else if(tmpscr->flags&fITEM)
19009 1157 hasitem=1;
19010
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1747 times.
1811 else if(tmpscr->enemyflags&efCARRYITEM)
19011 64 hasitem=4; // Will be set to 2 by roaming_item
19012 else
19013
2/4
✓ Branch 0 taken 1747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1747 times.
✗ Branch 3 not taken.
3494 items.add(new item((zfix)tmpscr->itemx,
19014
6/12
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1732 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1747 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1747 times.
✗ Branch 11 not taken.
1747 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19015
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1732 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1732 times.
✗ Branch 9 not taken.
1747 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19016
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1642 times.
1747 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
19017 1747 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19018 3027 }
19019 34360 }
19020
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 else if(!(DMaps[currdmap].flags&dmfCAVES))
19021 {
19022
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
19023
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
19024 {
19025 163 Item=tmpscr[1].catchall;
19026
19027
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
19028
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
324 items.add(new item((zfix)tmpscr->itemx,
19029
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 162 times.
✗ Branch 11 not taken.
162 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19030
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19031 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19032 163 }
19033 475 }
19034 35264 }
19035
19036 957 void never_return(int32_t index)
19037 {
19038
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
19039 191 goto doit;
19040
19041
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
19042
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 437 times.
✓ Branch 3 taken 543 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
19043 {
19044 437 goto dontdoit;
19045 329 }
19046
19047 doit:
19048 520 setmapflag(mNEVERRET);
19049 dontdoit:
19050 957 return;
19051 }
19052
19053 63438 bool slowguy(int32_t id)
19054 {
19055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63438 times.
63438 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19056 {
19057 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
19058 return false;
19059 }
19060 //return (guysbuf[id].step<100);
19061
2/2
✓ Branch 0 taken 53854 times.
✓ Branch 1 taken 9584 times.
63438 switch(id)
19062 {
19063 case eOCTO1S:
19064 case eOCTO2S:
19065 case eOCTO1F:
19066 case eOCTO2F:
19067 case eLEV1:
19068 case eLEV2:
19069 case eROCK:
19070 case eBOULDER:
19071 9584 return true;
19072 }
19073
19074 53854 return false;
19075 63438 }
19076
19077 82767 bool ok2add(int32_t id)
19078 {
19079
2/4
✓ Branch 0 taken 82767 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82767 times.
82767 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
19080 {
19081 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
19082 return false;
19083 }
19084
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 81938 times.
✓ Branch 2 taken 365 times.
✓ Branch 3 taken 464 times.
82767 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
19085 464 return false;
19086
19087
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81662 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82303 switch(guysbuf[id].family)
19088 {
19089 // I added a special case for shooters because having traps on the same screen
19090 // was preventing them from spawning due to TMPNORET. This means they will
19091 // never stay dead, though, so it may not be the best solution. - Saf
19092 case eePROJECTILE:
19093 376 return true;
19094
19095
19096 case eeDIG:
19097 {
19098
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].misc10)
19099 {
19100 case 1:
19101
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
19102 79 return !getmapflag(mTMPNORET);
19103
19104 47 return true;
19105
19106 75 case 0:
19107 default:
19108 75 return true;
19109 }
19110 }
19111 case eeGANON:
19112 case eeTRAP:
19113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
19114
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
19115 [[fallthrough]];
19116 default:
19117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81662 times.
81662 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
19118 81662 break;
19119 }
19120
19121
2/2
✓ Branch 0 taken 20881 times.
✓ Branch 1 taken 60781 times.
81662 if(!get_qr(qr_NOTMPNORET))
19122 60781 return !getmapflag(mTMPNORET);
19123
19124 20881 return true;
19125 82767 }
19126
19127 1408981 void activate_fireball_statue(int32_t pos)
19128 {
19129
3/4
✓ Branch 0 taken 287785 times.
✓ Branch 1 taken 1121196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287785 times.
1408981 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
19130 {
19131 1121196 return;
19132 }
19133
19134 287785 int32_t cx=-1000, cy=-1000;
19135 287785 int32_t x = (pos&15)<<4;
19136 287785 int32_t y = pos&0xF0;
19137
19138 287785 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19139
19140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287785 times.
287785 if(!isfixedtogrid(statueID))
19141 {
19142
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 286277 times.
287785 if(ctype==cL_STATUE)
19143 {
19144 1508 cx=x+4;
19145 1508 cy=y+7;
19146 1508 }
19147
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 284962 times.
286277 else if(ctype==cR_STATUE)
19148 {
19149 1315 cx=x-8;
19150 1315 cy=y-1;
19151 1315 }
19152
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 1213 times.
284962 else if(ctype==cC_STATUE)
19153 {
19154 1213 cx=x;
19155 1213 cy=y;
19156 1213 }
19157 287785 }
19158 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
19159 {
19160 cx=x;
19161 cy=y;
19162 }
19163
19164
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 4036 times.
287785 if(cx!=-1000) // No point creating it if this is false
19165 {
19166
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
19167 {
19168
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
19169 {
19170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
19171 4 return; // No point deleting it. A script might be toying with it in some way.
19172 else
19173 guys.del(j);
19174 }
19175 9750 }
19176
19177 4032 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
19178 4032 }
19179 1408981 }
19180
19181 34956 void activate_fireball_statues()
19182 {
19183
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 33543 times.
34956 if(!(tmpscr->enemyflags&efFIREBALLS))
19184 {
19185 33543 return;
19186 }
19187
19188
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 248688 times.
250101 for(int32_t i=0; i<176; i++)
19189 {
19190 248688 activate_fireball_statue(i);
19191 248688 }
19192 34956 }
19193
19194 34956 void load_default_enemies()
19195 {
19196 34956 wallm_load_clk=frame-80;
19197
19198
2/2
✓ Branch 0 taken 33076 times.
✓ Branch 1 taken 1880 times.
34956 if(tmpscr->enemyflags&efZORA)
19199 {
19200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1880 times.
1880 if(zoraID>=0)
19201 1880 addenemy(-16, -16, zoraID, 0);
19202 1880 }
19203
19204
2/2
✓ Branch 0 taken 34778 times.
✓ Branch 1 taken 178 times.
34956 if(tmpscr->enemyflags&efTRAP4)
19205 {
19206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
19207 {
19208 178 addenemy(32, 32, cornerTrapID, -14);
19209 178 addenemy(208, 32, cornerTrapID, -14);
19210 178 addenemy(32, 128, cornerTrapID, -14);
19211 178 addenemy(208, 128, cornerTrapID, -14);
19212 178 }
19213 178 }
19214
19215
2/2
✓ Branch 0 taken 384516 times.
✓ Branch 1 taken 34956 times.
419472 for(int32_t y=0; y<176; y+=16)
19216 {
19217
2/2
✓ Branch 0 taken 6152256 times.
✓ Branch 1 taken 384516 times.
6536772 for(int32_t x=0; x<256; x+=16)
19218 {
19219 6152256 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19220 6152256 int32_t cflag = MAPFLAG(x, y);
19221 6152256 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19222
19223
4/6
✓ Branch 0 taken 6152256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151950 times.
✓ Branch 3 taken 306 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151950 times.
6152256 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
19224 {
19225
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 296 times.
306 if(trapLOSHorizontalID>=0)
19226 296 addenemy(x, y, trapLOSHorizontalID, -14);
19227 306 }
19228
4/6
✓ Branch 0 taken 6151950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151744 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151744 times.
6151950 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
19229 {
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
19231 206 addenemy(x, y, trapLOSVerticalID, -14);
19232 206 }
19233
4/6
✓ Branch 0 taken 6151744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151466 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151466 times.
6151744 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
19234 {
19235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
19236 {
19237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(addenemy(x, y, trapLOS4WayID, -14))
19238 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
19239 278 }
19240 278 }
19241
19242
4/6
✓ Branch 0 taken 6151466 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151067 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151067 times.
6151466 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
19243 {
19244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
19245 399 addenemy(x, y, trapConstantHorizontalID, -14);
19246 399 }
19247
4/6
✓ Branch 0 taken 6151067 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6150634 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6150634 times.
6151067 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
19248 {
19249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
19250 433 addenemy(x, y, trapConstantVerticalID, -14);
19251 433 }
19252
19253
1/2
✓ Branch 0 taken 6152256 times.
✗ Branch 1 not taken.
6152256 if(ctype==cSPINTILE1)
19254 {
19255 // Awaken spinning tile
19256 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
19257 }
19258 6152256 }
19259 384516 }
19260
19261
2/2
✓ Branch 0 taken 34900 times.
✓ Branch 1 taken 56 times.
34956 if(tmpscr->enemyflags&efTRAP2)
19262 {
19263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
19264 {
19265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(64, 80, centerTrapID, -14))
19266 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19267
19268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(176, 80, centerTrapID, -14))
19269 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19270 56 }
19271 56 }
19272
19273
2/2
✓ Branch 0 taken 34873 times.
✓ Branch 1 taken 83 times.
34956 if(tmpscr->enemyflags&efROCKS)
19274 {
19275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
19276 {
19277 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19278 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19279 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19280 83 }
19281 83 }
19282
19283 34956 activate_fireball_statues();
19284 34956 }
19285
19286 44610086 void update_slope_combopos(int32_t lyr, int32_t pos)
19287 {
19288
2/4
✓ Branch 0 taken 44610086 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44610086 times.
44610086 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
19289 44610086 mapscr* s = FFCore.tempScreens[lyr];
19290 44610086 newcombo const& cmb = combobuf[s->data[pos]];
19291
19292 44610086 auto id = (176*lyr)+pos;
19293 44610086 auto it = slopes.find(id);
19294
19295 44610086 bool wasSlope = it!=slopes.end();
19296 44610086 bool isSlope = cmb.type == cSLOPE;
19297
19298
3/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 44609883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203 times.
44610086 if(isSlope && !wasSlope)
19299 {
19300 203 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
19301 203 }
19302
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44609883 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44609883 else if(wasSlope && !isSlope)
19303 {
19304 slopes.erase(it);
19305 }
19306 44610086 }
19307 35327 void update_slope_comboposes()
19308 {
19309
2/2
✓ Branch 0 taken 247289 times.
✓ Branch 1 taken 35327 times.
282616 for(auto lyr = 0; lyr < 7; ++lyr)
19310 {
19311
2/2
✓ Branch 0 taken 43522864 times.
✓ Branch 1 taken 247289 times.
43770153 for(auto pos = 0; pos < 176; ++pos)
19312 43522864 update_slope_combopos(lyr,pos);
19313 247289 }
19314 35327 }
19315
19316 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
19317 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
19318 1160293 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
19319 {
19320 1160293 delete_fireball_shooter(s, pos);
19321 1160293 }
19322
19323 //Placeholder in case we need it.
19324 void screen_ffc_modify_preroutine(word index)
19325 {
19326 return;
19327 }
19328
19329 // Everything that must be done after we change a screen's combo to another combo. -L
19330 1160293 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
19331 {
19332 1160293 s->valid |= mVALID;
19333 1160293 activate_fireball_statue(pos);
19334
19335
2/2
✓ Branch 0 taken 1160199 times.
✓ Branch 1 taken 94 times.
1160293 if(combobuf[s->data[pos]].type==cSPINTILE1)
19336 {
19337 // Awaken spinning tile
19338 94 awaken_spinning_tile(s,pos);
19339 94 }
19340 1160293 int32_t lyr = -1;
19341
2/2
✓ Branch 0 taken 118155 times.
✓ Branch 1 taken 1042138 times.
1160293 if(s == tmpscr) lyr = 0;
19342
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 593895 times.
666966 else for(size_t q = 0; q < 6; ++q)
19343 {
19344
2/2
✓ Branch 0 taken 45084 times.
✓ Branch 1 taken 548811 times.
593895 if(s == tmpscr2+q)
19345 {
19346 45084 lyr = q+1;
19347 45084 break;
19348 }
19349 548811 }
19350
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 1087222 times.
1160293 if(lyr > -1)
19351 1087222 update_slope_combopos(lyr,pos);
19352 1160293 }
19353
19354 8780583 void screen_ffc_modify_postroutine(word index)
19355 {
19356 8780583 ffcdata& ff = tmpscr->ffcs[index];
19357 8780583 newcombo const& cmb = combobuf[ff.data];
19358
19359 8780583 auto id = (176*7)+int32_t(index);
19360 8780583 auto it = slopes.find(id);
19361
19362 8780583 bool wasSlope = it!=slopes.end();
19363
1/2
✓ Branch 0 taken 8780583 times.
✗ Branch 1 not taken.
8780583 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
19364
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8780583 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8780583 if(isSlope && !wasSlope)
19365 {
19366 slopes.try_emplace(id, nullptr, &ff, id);
19367 }
19368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8780583 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8780583 else if(wasSlope && !isSlope)
19369 {
19370 slopes.erase(it);
19371 }
19372
19373 8780583 tmpscr->ffcCountMarkDirty();
19374 8780583 }
19375
19376 4404 void screen_combo_modify_pre(int32_t cid)
19377 {
19378
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
19379 {
19380 30828 mapscr* t = FFCore.tempScreens[lyr];
19381
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
19382 {
19383
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
19384 {
19385 6601 screen_combo_modify_preroutine(t,i);
19386 6601 }
19387 5425728 }
19388 30828 }
19389 4404 }
19390 4404 void screen_combo_modify_post(int32_t cid)
19391 {
19392
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
19393 {
19394 30828 mapscr* t = FFCore.tempScreens[lyr];
19395
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
19396 {
19397
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
19398 {
19399 6601 screen_combo_modify_postroutine(t,i);
19400 6601 }
19401 5425728 }
19402 30828 }
19403
2/2
✓ Branch 0 taken 563712 times.
✓ Branch 1 taken 4404 times.
568116 for(word ind = 0; ind < MAXFFCS; ++ind)
19404 {
19405
2/2
✓ Branch 0 taken 563462 times.
✓ Branch 1 taken 250 times.
563712 if(tmpscr->ffcs[ind].data == cid)
19406 250 screen_ffc_modify_postroutine(ind);
19407 563712 }
19408 4404 }
19409
19410 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
19411 {
19412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
19413 94 }
19414
19415
19416 // It stands for next_side_pos
19417 11436 void nsp(bool random)
19418 // moves sle_x and sle_y to the next position
19419 {
19420
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8175 times.
11436 if(random)
19421 {
19422
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
19423 {
19424 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
19425 1634 sle_y = (zc_oldrand()%10)*16;
19426 1634 }
19427 else
19428 {
19429 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
19430 1627 sle_x = (zc_oldrand()%15)*16;
19431 }
19432
19433 3261 return;
19434 }
19435
19436
2/2
✓ Branch 0 taken 6151 times.
✓ Branch 1 taken 2024 times.
8175 if(sle_x==0)
19437 {
19438
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 179 times.
2024 if(sle_y<160)
19439 1845 sle_y+=16;
19440 else
19441 179 sle_x+=16;
19442 2024 }
19443
2/2
✓ Branch 0 taken 2581 times.
✓ Branch 1 taken 3570 times.
6151 else if(sle_y==160)
19444 {
19445
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 165 times.
2581 if(sle_x<240)
19446 2416 sle_x+=16;
19447 else
19448 165 sle_y-=16;
19449 2581 }
19450
2/2
✓ Branch 0 taken 1550 times.
✓ Branch 1 taken 2020 times.
3570 else if(sle_x==240)
19451 {
19452
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 148 times.
1550 if(sle_y>0)
19453 1402 sle_y-=16;
19454 else
19455 148 sle_x-=16;
19456 1550 }
19457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
19458 {
19459
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
19460 2020 sle_x-=16;
19461 else
19462 sle_y+=16;
19463 2020 }
19464 11436 }
19465
19466 2426 int32_t next_side_pos(bool random)
19467 // moves sle_x and sle_y to the next available position
19468 // returns the direction the enemy should face
19469 {
19470 bool blocked;
19471 2426 int32_t c=0;
19472
19473 2426 do
19474 {
19475
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11305 times.
11436 nsp(c>35 ? false : random);
19476
4/4
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 8992 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2425 times.
13861 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19477
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19478
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2425 times.
✗ Branch 3 not taken.
2425 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19479
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2425 times.
2425 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19480 2425 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19481
19482
2/2
✓ Branch 0 taken 11435 times.
✓ Branch 1 taken 1 times.
11436 if(++c>50)
19483 1 return -1;
19484
2/2
✓ Branch 0 taken 9010 times.
✓ Branch 1 taken 2425 times.
11435 }
19485 11435 while(blocked);
19486
19487 2425 int32_t dir=0;
19488
19489
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 735 times.
2425 if(sle_x==0) dir=right;
19490
19491
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 569 times.
2425 if(sle_y==0) dir=down;
19492
19493
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 706 times.
2425 if(sle_x==240) dir=left;
19494
19495
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 if(sle_y==168) dir=up;
19496
19497 2425 return dir;
19498 2426 }
19499
19500 bool can_side_load(int32_t id)
19501 {
19502 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19503 {
19504 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
19505 return false;
19506 }
19507 switch(guysbuf[id].family) //id&0x0FFF)
19508 {
19509 //case eTEK1:
19510 //case eTEK2:
19511 //case eTEK3:
19512 //case eLEV1:
19513 //case eLEV2:
19514 //case eLEV3:
19515 //case eRAQUAM:
19516 //case eLAQUAM:
19517 //case eDODONGO:
19518 //case eMANHAN:
19519 //case eGLEEOK1:
19520 //case eGLEEOK2:
19521 //case eGLEEOK3:
19522 //case eGLEEOK4:
19523 //case eDIG1:
19524 //case eDIG3:
19525 //case eGOHMA1:
19526 //case eGOHMA2:
19527 //case eCENT1:
19528 //case eCENT2:
19529 //case ePATRA1:
19530 //case ePATRA2:
19531 //case eGANON:
19532 //case eMANHAN2:
19533 //case eCEILINGM: later
19534 //case eFLOORM: later
19535 //case ePATRABS:
19536 //case ePATRAL2:
19537 //case ePATRAL3:
19538 //case eGLEEOK1F:
19539 //case eGLEEOK2F:
19540 //case eGLEEOK3F:
19541 //case eGLEEOK4F:
19542 //case eDODONGOBS:
19543 //case eDODONGOF:
19544 //case eGOHMA3:
19545 //case eGOHMA4:
19546 //case eSHOOTMAGIC:
19547 //case eSHOOTROCK:
19548 //case eSHOOTSPEAR:
19549 //case eSHOOTSWORD:
19550 //case eSHOOTFLAME:
19551 //case eSHOOTFLAME2:
19552 //case eSHOOTFBALL:
19553 case eeTEK:
19554 case eeLEV:
19555 case eeAQUA:
19556 case eeDONGO:
19557 case eeMANHAN:
19558 case eeGLEEOK:
19559 case eeDIG:
19560 case eeGHOMA:
19561 case eeLANM:
19562 case eePATRA:
19563 case eeGANON:
19564 case eePROJECTILE:
19565 return false;
19566 break;
19567 }
19568
19569 return true;
19570 }
19571
19572 static bool script_sle = false;
19573 static int32_t sle_pattern = 0;
19574 void script_side_load_enemies()
19575 {
19576 if(script_sle || sle_clk) return;
19577 sle_cnt = 0;
19578 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19579 ++sle_cnt;
19580 script_sle = true;
19581 sle_pattern = tmpscr->pattern;
19582 sle_clk = 0;
19583 }
19584
19585 54442 void side_load_enemies()
19586 {
19587
3/4
✓ Branch 0 taken 54442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 682 times.
54442 if(!script_sle && sle_clk==0)
19588 {
19589 682 sle_pattern = tmpscr->pattern;
19590 682 sle_cnt = 0;
19591 682 int32_t guycnt = 0;
19592 682 int16_t s = (currmap<<7)+currscr;
19593 682 bool beenhere=false;
19594 682 bool reload=true;
19595 682 bool unbeatablereload = true;
19596
19597 682 load_default_enemies();
19598
19599
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 682 times.
4774 for(int32_t i=0; i<6; i++)
19600
2/2
✓ Branch 0 taken 3889 times.
✓ Branch 1 taken 203 times.
4295 if(visited[i]==s)
19601 203 beenhere=true;
19602
19603
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 479 times.
682 if(!beenhere)
19604 {
19605 479 visited[vhead]=s;
19606 479 vhead = (vhead+1)%6;
19607 479 }
19608
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 42 times.
203 else if(game->guys[s]==0)
19609 {
19610 42 sle_cnt=0;
19611 42 reload=false;
19612 42 }
19613
19614
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 640 times.
682 if(reload)
19615 {
19616 640 sle_cnt = game->guys[s];
19617
19618
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 220 times.
640 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19619 640 || sle_cnt==0)
19620 {
19621
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 220 times.
1270 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19622 1050 ++sle_cnt;
19623 220 }
19624
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 479 times.
✗ Branch 3 not taken.
640 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19625 {
19626 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19627 {
19628 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
19629 {
19630 unbeatablereload = false;
19631 }
19632 }
19633 if (unbeatablereload)
19634 {
19635 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19636 {
19637 ++sle_cnt;
19638 }
19639 }
19640 }
19641 640 }
19642
19643
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 651 times.
682 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19644 {
19645 31 sle_cnt = 0;
19646
19647
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19648 108 ++sle_cnt;
19649 31 }
19650
19651
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 682 times.
3124 for(int32_t i=0; i<sle_cnt; i++)
19652 2442 ++guycnt;
19653
19654 682 game->guys[s] = guycnt;
19655 682 }
19656
19657
2/2
✓ Branch 0 taken 52016 times.
✓ Branch 1 taken 2426 times.
54442 if((++sle_clk+8)%24 == 0)
19658 {
19659 2426 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19660
19661
4/4
✓ Branch 0 taken 2425 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 2193 times.
2426 if(dir==-1 || tooclose(sle_x,sle_y,32))
19662 {
19663 233 return;
19664 }
19665
19666 2193 int32_t enemy_slot=guys.Count();
19667
19668
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2193 times.
2193 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19669 sle_cnt--;
19670
19671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(sle_cnt > 0)
19672 {
19673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19674 {
19675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19676 {
19677 2193 guys.spr(enemy_slot)->dir = dir;
19678 2193 }
19679
1/2
✓ Branch 0 taken 2193 times.
✗ Branch 1 not taken.
2193 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19680 {
19681 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19682 {
19683 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19684 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19685 }
19686 }
19687 2193 }
19688 2193 }
19689 2193 }
19690
19691
2/2
✓ Branch 0 taken 53631 times.
✓ Branch 1 taken 578 times.
54209 if(sle_cnt<=0)
19692 {
19693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if(script_sle)
19694 script_sle = false;
19695 578 else loaded_enemies=true;
19696 578 sle_clk = 0;
19697 578 }
19698 54442 }
19699
19700 1208111 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19701 {
19702
19703
4/4
✓ Branch 0 taken 1105227 times.
✓ Branch 1 taken 102884 times.
✓ Branch 2 taken 102884 times.
✓ Branch 3 taken 1208111 times.
1208111 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19704 {
19705 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
19706 205768 return false; //never 0, never OoB.
19707 }
19708 // No corner enemies
19709
6/6
✓ Branch 0 taken 1042351 times.
✓ Branch 1 taken 165760 times.
✓ Branch 2 taken 40016 times.
✓ Branch 3 taken 1082367 times.
✓ Branch 4 taken 114320 times.
✓ Branch 5 taken 91456 times.
1208111 if((x==0 || x==240) && (y==0 || y==160))
19710
19711 205776 return false;
19712
19713 //Is a no spawn combo...
19714
4/4
✓ Branch 0 taken 1082355 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1082351 times.
1082367 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19715 16 return false;
19716
19717 // No enemies in dungeon walls
19718
10/10
✓ Branch 0 taken 655073 times.
✓ Branch 1 taken 427278 times.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 509953 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 422881 times.
✓ Branch 7 taken 87072 times.
✓ Branch 8 taken 87072 times.
✓ Branch 9 taken 335809 times.
1082351 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19719 319264 return false;
19720
19721 // Too close
19722
4/4
✓ Branch 0 taken 74233 times.
✓ Branch 1 taken 688854 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 74132 times.
763087 if(tooclose(x,y,40) && t<11)
19723 74132 return false;
19724
19725 // Can't fly onto it?
19726
4/4
✓ Branch 0 taken 122271 times.
✓ Branch 1 taken 566684 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 17932 times.
742847 if(isflier(tmpscr->enemy[i])&&
19727
2/2
✓ Branch 0 taken 121881 times.
✓ Branch 1 taken 390 times.
122271 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19728
2/2
✓ Branch 0 taken 53892 times.
✓ Branch 1 taken 67989 times.
121881 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19729 18322 return false;
19730
19731 // Can't jump onto it?
19732 if
19733 (
19734
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 86588 times.
757225 guysbuf[tmpscr->enemy[i]].family==eeTEK
19735
19736
2/2
✓ Branch 0 taken 86606 times.
✓ Branch 1 taken 584027 times.
670633 &&
19737 (
19738
2/2
✓ Branch 0 taken 86599 times.
✓ Branch 1 taken 7 times.
86606 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19739
2/2
✓ Branch 0 taken 86598 times.
✓ Branch 1 taken 1 times.
86599 COMBOTYPE(x+8,y+8)==cNOENEMY||
19740
1/2
✓ Branch 0 taken 86598 times.
✗ Branch 1 not taken.
86598 ispitfall(x+8,y+8)||
19741
2/2
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 6 times.
86598 MAPFLAG(x+8,y+8)==mfNOENEMY||
19742 86592 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19743 )
19744 )
19745 {
19746 18 return false;
19747 }
19748
19749 // Other off-limit combos
19750
6/6
✓ Branch 0 taken 566670 times.
✓ Branch 1 taken 103945 times.
✓ Branch 2 taken 480082 times.
✓ Branch 3 taken 86588 times.
✓ Branch 4 taken 263616 times.
✓ Branch 5 taken 216466 times.
1150697 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19751
2/2
✓ Branch 0 taken 268958 times.
✓ Branch 1 taken 211124 times.
480082 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19752 480082 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19753 216466 return false;
19754
19755 // Don't ever generate enemies on these combos!
19756
4/4
✓ Branch 0 taken 453853 times.
✓ Branch 1 taken 296 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 453859 times.
454149 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19757 302 return false;
19758
19759 //BS Dodongos need at least 2 spaces.
19760
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 452820 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
453859 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
19761 {
19762
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19763
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19764
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19765 ((y>144)||_walkflag(x, y+24,2)))
19766 {
19767 return false;
19768 }
19769 19 }
19770
19771 453853 return true;
19772 1105227 }
19773
19774 159450 bool is_ceiling_pattern(int32_t i)
19775 {
19776
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 159430 times.
159450 return (i==pCEILING || i==pCEILINGR);
19777 }
19778
19779 5716 int32_t placeenemy(int32_t i)
19780 {
19781 5716 std::map<int32_t, int32_t> freeposcache;
19782 5716 int32_t frees = 0;
19783
19784
2/2
✓ Branch 0 taken 62876 times.
✓ Branch 1 taken 5716 times.
68592 for(int32_t y=0; y<176; y+=16)
19785 {
19786
2/2
✓ Branch 0 taken 1006016 times.
✓ Branch 1 taken 62876 times.
1068892 for(int32_t x=0; x<256; x+=16)
19787 {
19788
3/4
✓ Branch 0 taken 1006016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396120 times.
✓ Branch 3 taken 609896 times.
1006016 if(is_starting_pos(i,x,y,0))
19789 {
19790
1/2
✓ Branch 0 taken 396120 times.
✗ Branch 1 not taken.
396120 freeposcache[frees++] = (y&0xF0)+(x>>4);
19791 396120 }
19792 1006016 }
19793 62876 }
19794
19795
2/2
✓ Branch 0 taken 5705 times.
✓ Branch 1 taken 11 times.
5716 if(frees > 0)
19796
2/4
✓ Branch 0 taken 5705 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5705 times.
✗ Branch 3 not taken.
5705 return freeposcache[zc_oldrand()%frees];
19797
19798 11 return -1;
19799 5716 }
19800
19801 80536 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19802 {
19803 80536 bool placed=false;
19804 80536 int32_t t=-1;
19805
19806 // First: enemy combo flags
19807
2/2
✓ Branch 0 taken 800168 times.
✓ Branch 1 taken 63449 times.
863617 for(int32_t sy=0; sy<176; sy+=16)
19808 {
19809
2/2
✓ Branch 0 taken 12675481 times.
✓ Branch 1 taken 783081 times.
13458562 for(int32_t sx=0; sx<256; sx+=16)
19810 {
19811 12675481 int32_t cflag = MAPFLAG(sx, sy);
19812 12675481 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19813
19814
2/4
✓ Branch 0 taken 12675481 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12675481 times.
✗ Branch 3 not taken.
12675481 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19815 {
19816 if(!ok2add(tmpscr->enemy[i]))
19817 {
19818 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19819 }
19820 else
19821 {
19822 addenemy(sx,
19823 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19824 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19825
19826 ++guycnt;
19827
19828 placed=true;
19829 goto placed_enemy;
19830 }
19831 }
19832
19833
4/4
✓ Branch 0 taken 12658345 times.
✓ Branch 1 taken 17136 times.
✓ Branch 2 taken 12658345 times.
✓ Branch 3 taken 17136 times.
12675481 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19834 {
19835
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17087 times.
17136 if(!ok2add(tmpscr->enemy[i]))
19836 {
19837
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19838 49 }
19839 else
19840 {
19841 34174 addenemy(sx,
19842
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17086 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17087 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19843
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17086 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17087 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19844
19845 17087 ++guycnt;
19846
19847 17087 placed=true;
19848 17087 goto placed_enemy;
19849 }
19850 49 }
19851 12658394 }
19852 783081 }
19853
19854 // Next: enemy pattern
19855
6/8
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 58510 times.
✓ Branch 2 taken 57954 times.
✓ Branch 3 taken 5495 times.
✓ Branch 4 taken 57954 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57954 times.
63449 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19856 {
19857 57954 do
19858 {
19859
19860 // NES positions
19861 99432 pos%=9;
19862 99432 x=stx[loadside][pos];
19863 99432 y=sty[loadside][pos];
19864 99432 ++pos;
19865 99432 ++t;
19866
2/2
✓ Branch 0 taken 41478 times.
✓ Branch 1 taken 57954 times.
157386 }
19867
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99211 times.
99432 while((t< 20) && !is_starting_pos(i,x,y,t));
19868 57954 }
19869
19870
4/4
✓ Branch 0 taken 57954 times.
✓ Branch 1 taken 5495 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57733 times.
63449 if(t<0 || t >= 20) // above enemy pattern failed
19871 {
19872 // Final chance: find a random position anywhere onscreen
19873 5716 int32_t randpos = placeenemy(i);
19874
19875
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5705 times.
5716 if(randpos>-1)
19876 {
19877 5705 x=(randpos&15)<<4;
19878 5705 y= randpos&0xF0;
19879 5705 }
19880 else // All opportunities failed - abort
19881 {
19882 11 return;
19883 }
19884 5705 }
19885
19886 {
19887 63438 int32_t c=0;
19888 63438 c=clk;
19889
19890
2/2
✓ Branch 0 taken 9584 times.
✓ Branch 1 taken 53854 times.
63438 if(!slowguy(tmpscr->enemy[i]))
19891 53854 ++fastguys;
19892
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 7998 times.
9584 else if(fastguys>0)
19893 1586 c=-15*(i-fastguys+2);
19894 else
19895 7998 c=-15*(i+1);
19896
19897
4/6
✓ Branch 0 taken 28861 times.
✓ Branch 1 taken 34577 times.
✓ Branch 2 taken 28861 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28861 times.
63438 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19898 {
19899 // Special case for blue leevers
19900
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 26967 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
28861 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
19901 761 c=-15*(i+1);
19902 else
19903 28100 c=-15;
19904 28861 }
19905
19906
2/2
✓ Branch 0 taken 62638 times.
✓ Branch 1 taken 800 times.
63438 if(!ok2add(tmpscr->enemy[i]))
19907 {
19908
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19909 800 }
19910 else
19911 {
19912
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62638 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19913 {
19914
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62508 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
125276 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19915
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
62638 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19916
19917 62638 ++guycnt;
19918 62638 }
19919 }
19920
19921 63438 placed=true;
19922 63438 } // if(t < 20)
19923
19924 placed_enemy:
19925
19926 // I don't like this, but it seems to work...
19927 static bool foundCarrier;
19928
19929
2/2
✓ Branch 0 taken 59157 times.
✓ Branch 1 taken 21368 times.
80525 if(i==0)
19930 21368 foundCarrier=false;
19931
19932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80525 times.
80525 if(placed)
19933 {
19934
4/4
✓ Branch 0 taken 21368 times.
✓ Branch 1 taken 59157 times.
✓ Branch 2 taken 21199 times.
✓ Branch 3 taken 169 times.
80525 if(i==0 && tmpscr->enemyflags&efLEADER)
19935 {
19936 169 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19937
19938
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if(index!=-1)
19939 {
19940 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19941
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(index!=-1)
19943 {
19944 162 ((enemy*)guys.spr(index))->leader = true;
19945 162 }
19946 162 }
19947 169 }
19948
19949
4/4
✓ Branch 0 taken 80302 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 80238 times.
✓ Branch 3 taken 64 times.
80525 if(!foundCarrier && hasitem&(4|2))
19950 {
19951 64 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19952
19953
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
19954 {
19955 64 ((enemy*)guys.spr(index))->itemguy = true;
19956 64 foundCarrier=true;
19957 64 }
19958 64 }
19959 80525 }
19960 80536 }
19961
19962 bool scriptloadenemies()
19963 {
19964 loaded_enemies = true;
19965 if(script_sle || sle_clk) return false;
19966 if(tmpscr->pattern==pNOSPAWN) return false;
19967
19968 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19969 {
19970 script_side_load_enemies();
19971 return true;
19972 }
19973
19974 int32_t pos=zc_oldrand()%9;
19975 int32_t clk=-15,x=0,y=0,fastguys=0;
19976 int32_t i=0,guycnt=0;
19977 int32_t loadcnt = 10;
19978
19979 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19980 {
19981 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19982 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19983 if (guys.Count() > preguycount)
19984 {
19985 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19986 {
19987 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19988 {
19989 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19990 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19991 }
19992 }
19993 }
19994 --clk;
19995 }
19996 return true;
19997 }
19998
19999 14124687 void loadenemies()
20000 {
20001
3/4
✓ Branch 0 taken 14124687 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 14070927 times.
14124687 if(script_sle || sle_clk)
20002 {
20003 53760 side_load_enemies();
20004 53760 return;
20005 }
20006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14070927 times.
14070927 if(tmpscr->pattern==pNOSPAWN) return;
20007
2/2
✓ Branch 0 taken 14035881 times.
✓ Branch 1 taken 35046 times.
14070927 if(loaded_enemies)
20008 14035881 return;
20009
20010 // check if it's the dungeon boss and it has been beaten before
20011
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34687 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
35046 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
20012 {
20013 90 loaded_enemies = true;
20014 90 return;
20015 }
20016
20017
4/4
✓ Branch 0 taken 34515 times.
✓ Branch 1 taken 441 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 34274 times.
34956 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
20018 {
20019 682 side_load_enemies();
20020 682 return;
20021 }
20022
20023 34274 loaded_enemies=true;
20024
20025 // do enemies that are always loaded
20026 34274 load_default_enemies();
20027
20028 // dungeon basements
20029
20030 static byte dngn_enemy_x[4] = {32,96,144,208};
20031
20032
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 33370 times.
34274 if(currscr>=128)
20033 {
20034
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 if(DMaps[currdmap].flags&dmfCAVES) return;
20035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
20036 {
20037 for(int32_t i=0; i<10; i++)
20038 {
20039 if ( tmpscr->enemy[i] )
20040 {
20041 int32_t preguycount = guys.Count();
20042 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
20043 if (guys.Count() > preguycount)
20044 {
20045 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20046 {
20047 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20048 {
20049 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20050 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20051 }
20052 }
20053 }
20054 }
20055 }
20056 }
20057 else
20058 {
20059
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
20060 {
20061 1900 int32_t preguycount = guys.Count();
20062
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
20063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
20064 {
20065
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20066 {
20067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20068 {
20069 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20070 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20071 4 }
20072 4 }
20073 1900 }
20074 1900 }
20075 }
20076 475 return;
20077 }
20078
20079 // check if it's been long enough to reload all enemies
20080
20081 33370 int32_t loadcnt = 10;
20082 33370 int16_t s = (currmap<<7)+currscr;
20083 33370 bool beenhere = false;
20084 33370 bool reload = true;
20085 33370 bool unbeatablereload = true;
20086
20087
2/2
✓ Branch 0 taken 200220 times.
✓ Branch 1 taken 33370 times.
233590 for(int32_t i=0; i<6; i++)
20088
2/2
✓ Branch 0 taken 191041 times.
✓ Branch 1 taken 9179 times.
209399 if(visited[i]==s)
20089 9179 beenhere = true;
20090
20091
2/2
✓ Branch 0 taken 9179 times.
✓ Branch 1 taken 24191 times.
33370 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
20092 {
20093 24191 visited[vhead]=s; //If not, it adds it to the array,
20094 24191 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
20095 24191 }
20096
2/2
✓ Branch 0 taken 4611 times.
✓ Branch 1 taken 4568 times.
9179 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
20097 {
20098 4568 loadcnt = 0; //It will tell it not to load any enemies,
20099 4568 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
20100 4568 }
20101
20102
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 28802 times.
33370 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
20103 {
20104 28802 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
20105
20106
2/4
✓ Branch 0 taken 10143 times.
✓ Branch 1 taken 18659 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28802 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
20107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10143 times.
10143 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
20108 18659 loadcnt = 10; //That means all enemies need to be respawned.
20109
3/4
✓ Branch 0 taken 24191 times.
✓ Branch 1 taken 4611 times.
✓ Branch 2 taken 24191 times.
✗ Branch 3 not taken.
28802 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
20110 {
20111 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
20112 {
20113 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
20114 {
20115 unbeatablereload = false;
20116 }
20117 }
20118 if (unbeatablereload)
20119 {
20120 loadcnt = 10;
20121 }
20122 }
20123 28802 }
20124
20125
4/4
✓ Branch 0 taken 31911 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 31724 times.
33370 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
20126 1646 loadcnt = 10; //All enemies also need to be respawned.
20127
20128 33370 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
20129 33370 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
20130 33370 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
20131
20132
4/4
✓ Branch 0 taken 14568 times.
✓ Branch 1 taken 99338 times.
✓ Branch 2 taken 80536 times.
✓ Branch 3 taken 33370 times.
113906 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
20133 {
20134 80536 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
20135 80536 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
20136
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 79725 times.
80536 if (guys.Count() > preguycount)
20137 {
20138
2/2
✓ Branch 0 taken 77378 times.
✓ Branch 1 taken 2347 times.
79725 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20139 {
20140
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2343 times.
2347 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20141 {
20142 2343 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20143 2343 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20144 2343 }
20145 2347 }
20146 79725 }
20147
20148 80536 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
20149 80536 }
20150
20151 33370 game->guys[s] = guycnt;
20152 //} //if(true)
20153 14124687 }
20154 233 void moneysign()
20155 {
20156 233 additem(48,108,iRupy,ipDUMMY);
20157 233 set_clip_state(pricesdisplaybuf, 0);
20158 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
20159 233 }
20160
20161 3252 void putprices(bool sign)
20162 {
20163
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3223 times.
3252 if(fadeclk > 0) return;
20164
20165 3223 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
20166 3223 int32_t step=32;
20167 3223 int32_t x=80;
20168
20169
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2942 times.
3223 if(prices[2]==0)
20170 {
20171 2942 step<<=1;
20172
20173
2/2
✓ Branch 0 taken 2910 times.
✓ Branch 1 taken 32 times.
2942 if(prices[1]==0)
20174 {
20175 2910 x=112;
20176 2910 }
20177 2942 }
20178
20179
2/2
✓ Branch 0 taken 3223 times.
✓ Branch 1 taken 9669 times.
12892 for(int32_t i=0; i<3; i++)
20180 {
20181 // Kind of stupid, but it works: 100000 is used to indicate that an item
20182 // has a price of zero rather than there being no item.
20183 // 100000 isn't a valid price, so this doesn't cause problems.
20184
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9669 if(prices[i]!=0 && prices[i]<100000)
20185 {
20186 char buf[8];
20187 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
20188
20189 1039 int32_t l=(int32_t)strlen(buf);
20190 1039 set_clip_state(pricesdisplaybuf, 0);
20191
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
20192 1039 }
20193
20194 9669 x+=step;
20195 9669 }
20196 3252 }
20197
20198 // Setting up special rooms
20199 // Also called when the Letter is used successfully.
20200 1202 void setupscreen()
20201 {
20202 1202 boughtsomething=false;
20203 1202 int32_t t=currscr<128?0:1;
20204 1202 word str=tmpscr[t].str;
20205
20206 // Prices are already set to 0 in dowarp()
20207
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1202 switch(tmpscr[t].room)
20208 {
20209 case rSP_ITEM: // special item
20210 161 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
20211 161 break;
20212
20213 case rINFO: // pay for info
20214 {
20215 28 int32_t count = 0;
20216 28 int32_t base = 88;
20217 28 int32_t step = 5;
20218
20219 28 moneysign();
20220
20221
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
20222 {
20223
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[tmpscr[t].catchall].str[i])
20224 {
20225 84 ++count;
20226 84 }
20227 else
20228 break;
20229 84 }
20230
20231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
20232 {
20233
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
20234 {
20235 base = 88+32;
20236 }
20237
20238
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
20239 {
20240 step = 6;
20241 }
20242
20243
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
20244 {
20245 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
20246 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20247 84 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
20248
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
20249 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20250 84 int32_t itemid = current_item_id(itype_wealthmedal);
20251
20252
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
20253 {
20254 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20255 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20256 else
20257 prices[i]-=itemsbuf[itemid].misc1;
20258 prices[i]=vbound(prices[i], -99999, 0);
20259 if(prices[i]==0)
20260 prices[i]=100000;
20261 }
20262
20263
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
20264 prices[i]=-1;
20265 84 }
20266 28 }
20267
20268 28 break;
20269 }
20270
20271 case rMONEY: // secret money
20272 44 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
20273 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20274 44 break;
20275
20276 case rGAMBLE: // gambling
20277 11 prices[0]=prices[1]=prices[2]=-10;
20278 11 moneysign();
20279 11 additem(88,89,iRupy,ipMONEY+ipDUMMY);
20280 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20281 11 additem(120,89,iRupy,ipMONEY+ipDUMMY);
20282 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20283 11 additem(152,89,iRupy,ipMONEY+ipDUMMY);
20284 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
20285 11 break;
20286
20287 case rREPAIR: // door repair
20288
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20289 // }
20290 13 repaircharge=tmpscr[t].catchall;
20291 13 break;
20292
20293 case rMUPGRADE: // upgrade magic
20294 2 adjustmagic=true;
20295 2 break;
20296
20297 case rLEARNSLASH: // learn slash attack
20298 2 learnslash=true;
20299 2 break;
20300
20301 case rRP_HC: // heart container or red potion
20302 17 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
20303 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20304 17 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
20305 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20306 17 break;
20307
20308 case rP_SHOP: // potion shop
20309
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
20310 {
20311 12 str=0;
20312 12 break;
20313 }
20314
20315 [[fallthrough]];
20316 case rTAKEONE: // take one
20317 case rSHOP: // shop
20318 {
20319 194 int32_t count = 0;
20320 194 int32_t base = 88;
20321 194 int32_t step = 5;
20322
20323
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(tmpscr[t].room != rTAKEONE)
20324 193 moneysign();
20325
20326 //count and align the stuff
20327
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
20328 {
20329
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
20330 {
20331 523 ++count;
20332 523 }
20333 else
20334 {
20335 37 break;
20336 }
20337 523 }
20338
20339
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
20340 {
20341 22 base = 88+32;
20342 22 }
20343
20344
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
20345 {
20346 15 step = 6;
20347 15 }
20348
20349
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
20350 {
20351 523 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
20352 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20353
20354
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(tmpscr[t].room != rTAKEONE)
20355 {
20356 521 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
20357
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
20358 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20359 521 int32_t itemid = current_item_id(itype_wealthmedal);
20360
20361
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
20362 {
20363
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20364 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20365 else
20366 prices[i]+=itemsbuf[itemid].misc1;
20367 9 prices[i]=vbound(prices[i], 0, 99999);
20368
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
20369 prices[i]=100000;
20370 9 }
20371
20372
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
20373 prices[i]=1;
20374 521 }
20375 523 }
20376
20377 194 break;
20378 }
20379 case rBOTTLESHOP: // bottle shop
20380 {
20381 1 int32_t count = 0;
20382 1 int32_t base = 88;
20383 1 int32_t step = 5;
20384
20385 1 moneysign();
20386 1 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
20387 //count and align the stuff
20388
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
20389 {
20390
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
20391 {
20392 3 ++count;
20393 3 }
20394 else
20395 {
20396 break;
20397 }
20398 3 }
20399
20400
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
20401 {
20402 base = 88+32;
20403 }
20404
20405
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
20406 {
20407 step = 6;
20408 }
20409
20410
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
20411 {
20412 3 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
20413 //{ Setup dummy item
20414 3 item* curItem = ((item*)items.spr(items.Count()-1));
20415 3 curItem->PriceIndex = i;
20416 3 newcombo const& cmb = combobuf[bst.comb[i]];
20417 3 curItem->o_tile = cmb.o_tile;
20418 3 curItem->o_cset = bst.cset[i];
20419 3 curItem->cs = curItem->o_cset;
20420 3 curItem->tile = cmb.o_tile;
20421 3 curItem->o_speed = cmb.speed;
20422 3 curItem->o_delay = 0;
20423 3 curItem->frames = cmb.frames;
20424 3 curItem->flip = cmb.flip;
20425 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
20426 3 curItem->pstring = 0;
20427 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
20428 3 curItem->flash = false;
20429 3 curItem->twohand = false;
20430 3 curItem->anim = true;
20431 3 curItem->hit_width=1;
20432 3 curItem->hyofs=4;
20433 3 curItem->hit_height=12;
20434 3 curItem->script=0;
20435 3 curItem->txsz=1;
20436 3 curItem->tysz=1;
20437 //}
20438
20439 3 prices[i] = bst.price[i];
20440
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
20441 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20442 3 int32_t itemid = current_item_id(itype_wealthmedal);
20443
20444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
20445 {
20446 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20447 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20448 else
20449 prices[i]+=itemsbuf[itemid].misc1;
20450 prices[i]=vbound(prices[i], 0, 99999);
20451 if(prices[i]==0)
20452 prices[i]=100000;
20453 }
20454
20455
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
20456 prices[i]=1;
20457 3 }
20458
20459 1 break;
20460 }
20461
20462 case rBOMBS: // more bombs
20463 19 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20464 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20465 19 prices[0]=-tmpscr[t].catchall;
20466 19 break;
20467
20468 case rARROWS: // more arrows
20469 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20470 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20471 prices[0]=-tmpscr[t].catchall;
20472 break;
20473
20474 case rSWINDLE: // leave heart container or money
20475 14 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
20476 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20477 14 prices[0]=-1;
20478 14 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20479 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20480 14 prices[1]=-tmpscr[t].catchall;
20481 14 break;
20482
20483 }
20484
20485
3/4
✓ Branch 0 taken 1183 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1183 times.
1202 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20486 {
20487 19 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20488 19 int32_t itemid = current_item_id(itype_wealthmedal);
20489
20490
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
20491 {
20492 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20493 prices[i]*=(itemsbuf[itemid].misc1/100.0);
20494 else
20495 prices[i]+=itemsbuf[itemid].misc1;
20496 }
20497
20498
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(tmpscr[t].catchall>1 && prices[i]>-1)
20499 prices[i]=-1;
20500 19 }
20501
20502 1202 putprices(false);
20503
20504
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 60 times.
1202 if(str)
20505 {
20506 1142 donewmsg(str);
20507 1142 }
20508 else
20509 {
20510 60 Hero.unfreeze();
20511 }
20512 1202 }
20513
20514 // Increments msgptr and returns the control code argument pointed at.
20515 3409 word grab_next_argument()
20516 {
20517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3409 times.
3409 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20518 3409 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20519 3409 word ret=val;
20520
20521 // If an argument is succeeded by 255, then it's a three-byte argument -
20522 // between 254 and 65535 (or whatever the maximum actually is)
20523
2/2
✓ Branch 0 taken 3285 times.
✓ Branch 1 taken 109 times.
3409 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20524
2/2
✓ Branch 0 taken 3394 times.
✓ Branch 1 taken 15 times.
3409 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20525 {
20526 109 val=MsgStrings[msgstr].s[msgptr+2];
20527 109 word next=val;
20528 109 ret += 254*next;
20529 109 msgptr+=2;
20530 109 }
20531
20532 3409 return ret;
20533 3409 }
20534
20535 enum
20536 {
20537 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20538 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20539
20540 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20541
20542 MNU_DATA_MAX
20543 };
20544 struct menu_choice
20545 {
20546 int32_t x, y;
20547 int32_t pos;
20548 int32_t upos, dpos, lpos, rpos;
20549 8 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20550 8 {}
20551 8 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20552 int32_t dpos, int32_t lpos, int32_t rpos)
20553 8 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20554 8 {}
20555 };
20556 static int32_t msg_menu_data[MNU_DATA_MAX];
20557 static bool do_run_menu = false;
20558 bool do_end_str = false;
20559 static bool wait_advance = false;
20560 351 static std::map<int32_t, menu_choice> menu_options;
20561 43098 void clr_msg_data()
20562 {
20563 43098 do_end_str = false;
20564 43098 wait_advance = false;
20565 43098 do_run_menu = false;
20566 43098 menu_options.clear();
20567 43098 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20568 43098 }
20569
20570 static bool doing_name_insert = false;
20571 static char namebuf[9] = {0};
20572 static char* nameptr = NULL;
20573 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20574 965 bool runMenuCursor()
20575 {
20576 965 clear_bitmap(msg_menu_bmp_buf);
20577
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!menu_options.size())
20578 {
20579 msg_menu_data[MNU_CHOSEN] = 0;
20580 return true; //end menu
20581 }
20582 965 int32_t pos = msg_menu_data[MNU_CHOSEN];
20583 //If the cursor is at an invalid pos, find the first pos >= 0...
20584
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20585 {
20586 pos = 0;
20587 while(menu_options.find(pos) == menu_options.end())
20588 ++pos;
20589 }
20590 965 menu_choice* ch = &menu_options[pos];
20591
20592 965 bool pressed = true;
20593
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 964 times.
965 if(rUp()) pos = ch->upos;
20594
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 962 times.
964 else if(rDown()) pos = ch->dpos;
20595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rLeft()) pos = ch->lpos;
20596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rRight()) pos = ch->rpos;
20597 962 else pressed = false;
20598
20599
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
965 if(pressed)
20600 3 msg_menu_data[MNU_TIMER] = 1;
20601
20602 965 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20603 965 bool held = false;
20604
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 48 times.
965 if(hold_input)
20605 {
20606 48 held = true;
20607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(Up()) pos = ch->upos;
20608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Down()) pos = ch->dpos;
20609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Left()) pos = ch->lpos;
20610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Right()) pos = ch->rpos;
20611 48 else held = false;
20612 48 }
20613 //If the cursor is at an invalid pos, find the first pos >= 0...
20614
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20615 {
20616 pos = 0;
20617 while(menu_options.find(pos) == menu_options.end())
20618 ++pos;
20619 }
20620
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 3 times.
965 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20621 3 sfx(MsgStrings[msgstr].sfx);
20622
20623 965 ch = &menu_options[pos];
20624 1930 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20625 965 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20626 965 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20627 965 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20628
20629 965 msg_menu_data[MNU_CHOSEN] = pos;
20630
20631
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 24 times.
965 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20632 {
20633 24 rAbtn(); //Eat
20634
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20635 24 }
20636
20637
3/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 962 times.
965 bool ret = (pressed || held) ? false : rAbtn();
20638 //Eat inputs
20639 965 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20640
20641
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 2 times.
965 if(ret)
20642 2 menu_options.clear();
20643
20644 965 return ret;
20645 //false if pos changed this frame; no confirming while moving the cursor!
20646 965 }
20647
20648 673819 bool bottom_margin_clip()
20649 {
20650 709016 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20651
2/2
✓ Branch 0 taken 638622 times.
✓ Branch 1 taken 35197 times.
673819 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20652 }
20653
20654 void update_msgstr();
20655 242981 bool parsemsgcode()
20656 {
20657
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 240294 times.
242981 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20658 240294 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20659
18/39
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 237259 times.
✓ Branch 2 taken 1276 times.
✓ Branch 3 taken 1463 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 68 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 122 times.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 8 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 4 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
240294 switch(c)
20660 {
20661 case MSGC_NEWLINE:
20662 {
20663 1276 ssc_tile_hei = ssc_tile_hei_buf;
20664
1/2
✓ Branch 0 taken 1276 times.
✗ Branch 1 not taken.
1276 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20665 1276 ssc_tile_hei_buf = -1;
20666 1276 cursor_y += thei + MsgStrings[msgstr].vspace;
20667 1276 cursor_x=msg_margins[left];
20668 1276 return true;
20669 }
20670
20671 case MSGC_COLOUR:
20672 {
20673 1463 int32_t cset = (grab_next_argument());
20674 1463 msgcolour = CSET(cset)+(grab_next_argument());
20675 1463 return true;
20676 }
20677
20678 case MSGC_SHDCOLOR:
20679 {
20680 int32_t cset = (grab_next_argument());
20681 msg_shdcol = CSET(cset)+(grab_next_argument());
20682 return true;
20683 }
20684 case MSGC_SHDTYPE:
20685 {
20686 msg_shdtype = grab_next_argument();
20687 return true;
20688 }
20689
20690 case MSGC_SPEED:
20691 {
20692 33 msgspeed=grab_next_argument();
20693 33 return true;
20694 }
20695
20696 case MSGC_CTRUP:
20697 {
20698 int32_t a1 = grab_next_argument();
20699 int32_t a2 = grab_next_argument();
20700 game->change_counter(a2, a1);
20701 return true;
20702 }
20703
20704 case MSGC_CTRDN:
20705 {
20706 2 int32_t a1 = grab_next_argument();
20707 2 int32_t a2 = grab_next_argument();
20708 2 game->change_counter(-a2, a1);
20709 2 return true;
20710 }
20711
20712 case MSGC_CTRSET:
20713 {
20714 int32_t a1 = grab_next_argument();
20715 int32_t a2 = grab_next_argument();
20716 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20717 return true;
20718 }
20719
20720 case MSGC_CTRUPPC:
20721 case MSGC_CTRDNPC:
20722 case MSGC_CTRSETPC:
20723 {
20724 2 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20725 2 int32_t counter = grab_next_argument();
20726 2 int32_t amount = grab_next_argument();
20727 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20728
20729
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(code==MSGC_CTRDNPC)
20730 amount*=-1;
20731
20732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(code==MSGC_CTRSETPC)
20733 game->set_counter(amount, counter);
20734 else
20735 2 game->change_counter(amount, counter);
20736
20737 2 return true;
20738 }
20739
20740 case MSGC_GIVEITEM:
20741 {
20742 68 int32_t itemID = grab_next_argument();
20743
20744 68 getitem(itemID, true);
20745
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20746 {
20747 68 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20748 68 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) > 0;
20749 68 }
20750 68 return true;
20751 }
20752
20753
20754 case MSGC_WARP:
20755 {
20756 int32_t dmap = grab_next_argument();
20757 int32_t scrn = grab_next_argument();
20758 int32_t dx = grab_next_argument();
20759 int32_t dy = grab_next_argument();
20760 int32_t wfx = grab_next_argument();
20761 int32_t sfx = grab_next_argument();
20762 if(dx >= MAX_SCC_ARG) dx = -1;
20763 if(dy >= MAX_SCC_ARG) dy = -1;
20764 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20765 do_end_str = true;
20766 return true;
20767 }
20768
20769 case MSGC_SETSCREEND:
20770 {
20771 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20772 int32_t screen = grab_next_argument();
20773 int32_t reg = grab_next_argument();
20774 int32_t val = grab_next_argument();
20775 FFCore.set_screen_d(screen + dmap, reg, val);
20776 return true;
20777 }
20778 case MSGC_TAKEITEM:
20779 {
20780 9 int32_t itemID = grab_next_argument();
20781
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( FFCore.doscript(ScriptType::Item, itemID) )
20782 {
20783 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20784 }
20785 9 takeitem(itemID);
20786
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_bwpn == itemID )
20787 {
20788 game->forced_bwpn = -1;
20789 } //not else if! -Z
20790
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_awpn == itemID )
20791 {
20792 game->forced_awpn = -1;
20793 }
20794
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_xwpn == itemID )
20795 {
20796 game->forced_xwpn = -1;
20797 } //not else if! -Z
20798
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_ywpn == itemID )
20799 {
20800 game->forced_ywpn = -1;
20801 }
20802 9 verifyBothWeapons();
20803 9 return true;
20804 }
20805
20806 case MSGC_SFX:
20807 {
20808 17 sfx((int32_t)grab_next_argument(),128);
20809 17 return true;
20810 }
20811
20812 case MSGC_MIDI:
20813 {
20814 7 int32_t music = (int32_t)(grab_next_argument());
20815
20816
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20817 1 music_stop();
20818 else
20819 6 jukebox(music+(ZC_MIDI_COUNT-1));
20820
20821 7 return true;
20822 }
20823
20824 case MSGC_NAME:
20825 {
20826 6 doing_name_insert = true;
20827 6 sprintf(namebuf, "%s", game->get_name());
20828 6 nameptr = namebuf;
20829 6 return true;
20830 }
20831
20832 case MSGC_FONT:
20833 {
20834 int fontid = grab_next_argument();
20835 int oh = text_height(msgfont);
20836 msgfont = get_zc_font(fontid);
20837 int nh = text_height(msgfont);
20838 int mh = std::max(oh,nh);
20839 if(mh > ssc_tile_hei_buf)
20840 ssc_tile_hei_buf = mh;
20841 return true;
20842 }
20843 case MSGC_RUN_FRZ_GENSCR:
20844 {
20845 word scr_id = grab_next_argument();
20846 bool force_redraw = grab_next_argument()!=0;
20847 if(force_redraw)
20848 {
20849 update_msgstr();
20850 draw_screen(tmpscr);
20851 }
20852 FFCore.runGenericFrozenEngine(scr_id);
20853 return true;
20854 }
20855 case MSGC_DRAWTILE:
20856 {
20857 int32_t tl = grab_next_argument();
20858 int32_t cs = grab_next_argument();
20859 int32_t t_wid = grab_next_argument();
20860 int32_t t_hei = grab_next_argument();
20861 int32_t fl = grab_next_argument();
20862
20863 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20864 {
20865 ssc_tile_hei = ssc_tile_hei_buf;
20866 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20867 ssc_tile_hei_buf = -1;
20868 cursor_y += thei + MsgStrings[msgstr].vspace;
20869 if(bottom_margin_clip()) return true;
20870 cursor_x=msg_margins[left];
20871 }
20872
20873 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20874 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20875 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20876 return true;
20877 }
20878
20879 case MSGC_GOTOIFRAND:
20880 {
20881 int32_t odds = (int32_t)(grab_next_argument());
20882
20883 if(!odds || !(zc_oldrand()%odds))
20884 goto switched;
20885
20886 (void)grab_next_argument();
20887 return true;
20888 }
20889
20890 case MSGC_GOTOIFGLOBAL:
20891 {
20892 int32_t arg = (int32_t)grab_next_argument();
20893 int32_t d = zc_min(7,arg);
20894 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20895 arg = (int32_t)grab_next_argument();
20896
20897 if(game->screen_d[s][d] >= arg)
20898 goto switched;
20899
20900 (void)grab_next_argument();
20901 return true;
20902 }
20903
20904 case MSGC_CHANGEPORTRAIT:
20905 {
20906 return true; //not implemented
20907 }
20908
20909 case MSGC_GOTOIFCREEND:
20910 {
20911 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20912 int32_t screen = grab_next_argument();
20913 int32_t reg = grab_next_argument();
20914 int32_t val = grab_next_argument();
20915 //int32_t nxtstr = grab_next_argument();
20916 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20917 {
20918 goto switched;
20919 }
20920 (void)grab_next_argument();
20921 return true;
20922 }
20923
20924 case MSGC_GOTOIF:
20925 {
20926 122 int32_t it = (int32_t)grab_next_argument();
20927
20928
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20929 35 goto switched;
20930
20931 87 (void)grab_next_argument();
20932 87 return true;
20933 }
20934
20935 case MSGC_GOTOIFCTR:
20936 {
20937
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20938 7 goto switched;
20939
20940 6 (void)grab_next_argument();
20941 6 return true;
20942 }
20943
20944 case MSGC_GOTOIFCTRPC:
20945 {
20946 int32_t counter = grab_next_argument();
20947 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20948
20949 if(game->get_counter(counter)>=amount)
20950 goto switched;
20951
20952 (void)grab_next_argument();
20953 return true;
20954 }
20955
20956 case MSGC_GOTOIFTRICOUNT:
20957 {
20958 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20959 goto switched;
20960
20961 (void)grab_next_argument();
20962 return true;
20963 }
20964
20965 case MSGC_GOTOIFTRI:
20966 {
20967 int32_t lev = (int32_t)(grab_next_argument());
20968
20969 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20970 goto switched;
20971
20972 (void)grab_next_argument();
20973 return true;
20974 }
20975
20976 case MSGC_SETUPMENU:
20977 {
20978 2 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20979 2 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20980 2 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20981 2 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20982 2 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20983 2 return true;
20984 }
20985
20986 case MSGC_MENUCHOICE:
20987 {
20988 8 int32_t pos = grab_next_argument();
20989 8 int32_t upos = grab_next_argument();
20990 8 int32_t dpos = grab_next_argument();
20991 8 int32_t lpos = grab_next_argument();
20992 8 int32_t rpos = grab_next_argument();
20993
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20994 {
20995 2 ssc_tile_hei = ssc_tile_hei_buf;
20996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20997 2 ssc_tile_hei_buf = -1;
20998 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
21000 2 cursor_x=msg_margins[left];
21001 2 }
21002
21003 16 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
21004 8 upos, dpos, lpos, rpos);
21005
21006
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
21007 8 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
21008 8 return true;
21009 }
21010
21011 case MSGC_RUNMENU:
21012 {
21013 2 msg_menu_data[MNU_CHOSEN] = 0;
21014 2 msg_menu_data[MNU_CAN_CONFIRM] = 0;
21015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(menu_options.size() < 1)
21016 return true;
21017 2 do_run_menu = true;
21018 2 return true;
21019 }
21020
21021 case MSGC_GOTOMENUCHOICE:
21022 {
21023 4 int32_t choice = grab_next_argument();
21024
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(msg_menu_data[MNU_CHOSEN] == choice)
21025 2 goto switched;
21026 2 (void)grab_next_argument();
21027 2 return true;
21028 }
21029
21030 case MSGC_ENDSTRING:
21031 {
21032 1 do_end_str = true;
21033 1 return true;
21034 }
21035 case MSGC_WAIT_ADVANCE:
21036 {
21037 wait_advance = true;
21038 linkedmsgclk = 51;
21039 return true;
21040 }
21041 case MSGC_TRIGSECRETS:
21042 {
21043 bool perm = (bool)grab_next_argument();
21044 hidden_entrance(0, true, false, -8);
21045 if(perm)
21046 setmapflag(mSECRET);
21047 return true;
21048 }
21049 case MSGC_TRIG_CMB_COPYCAT:
21050 {
21051 int copy_id = (int)grab_next_argument();
21052 if(copy_id == byte(copy_id))
21053 trig_copycat(copy_id);
21054 return true;
21055 }
21056 case MSGC_SETSCREENSTATE:
21057 {
21058 int32_t flag = int32_t(grab_next_argument());
21059 if(unsigned(flag)>=mMAXIND)
21060 {
21061 Z_error("SCC 133: Flag %d is invalid\n", flag);
21062 return true;
21063 }
21064 bool state = bool(grab_next_argument());
21065 if(state)
21066 setmapflag(1<<flag);
21067 else
21068 unsetmapflag(1<<flag,true);
21069 return true;
21070 }
21071 case MSGC_SETSCREENSTATER:
21072 {
21073 int32_t map = (int32_t)grab_next_argument();
21074 int32_t scrid = (int32_t)grab_next_argument();
21075 if(map < 1 || map > map_count)
21076 {
21077 Z_error("SCC 134: Map %d is invalid\n", map);
21078 return true;
21079 }
21080 if(unsigned(scrid)>=0x80)
21081 {
21082 Z_error("SCC 134: Screen %d is invalid\n", scrid);
21083 return true;
21084 }
21085
21086 int32_t flag = int32_t(grab_next_argument());
21087 if(unsigned(flag)>=mMAXIND)
21088 {
21089 Z_error("SCC 134: Flag %d is invalid\n", flag);
21090 return true;
21091 }
21092 bool state = bool(grab_next_argument());
21093 if(state)
21094 setmapflag(mapind(map,scrid),1<<flag);
21095 else
21096 unsetmapflag(mapind(map,scrid),1<<flag,true);
21097 return true;
21098 }
21099 switched:
21100 44 int32_t lev = (int32_t)(grab_next_argument());
21101
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
44 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
21102
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 31 times.
44 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
21103 {
21104 msgstr=lev;
21105 msgpos=msgptr=0;
21106 msgfont=setmsgfont();
21107 }
21108 else
21109 {
21110 44 donewmsg(lev);
21111 44 ssc_tile_hei_buf = -1;
21112 }
21113 44 msgptr--; // To counteract it being incremented after this routine is called.
21114 44 putprices(false);
21115 44 return true;
21116 }
21117
21118 237259 return false;
21119 242981 }
21120
21121 // Wraps the message string... probably.
21122 233741 void wrapmsgstr(char *s3)
21123 {
21124 233741 int32_t j=0;
21125
21126
2/2
✓ Branch 0 taken 23941 times.
✓ Branch 1 taken 209800 times.
233741 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21127 {
21128
2/2
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 19174 times.
23941 if(msgspace)
21129 {
21130 4767 char c = MsgStrings[msgstr].s[msgptr];
21131
4/6
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4440 times.
✗ Branch 5 not taken.
4767 if(c != ' ' && c >= 32 && c <= 126)
21132 {
21133
4/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 24450 times.
✓ Branch 2 taken 20132 times.
✓ Branch 3 taken 4440 times.
24572 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
21134 {
21135
3/4
✓ Branch 0 taken 19569 times.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19569 times.
20132 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
21136 20132 }
21137
21138 4440 s3[j] = 0;
21139 4440 msgspace = false;
21140 4440 }
21141 else
21142 {
21143 327 s3[0] = c;
21144 327 s3[1] = 0;
21145 }
21146 4767 }
21147 else
21148 {
21149 19174 s3[0] = MsgStrings[msgstr].s[msgptr];
21150 19174 s3[1] = 0;
21151
21152
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4045 times.
19174 if(s3[0] == ' ') msgspace=true;
21153 }
21154 23941 }
21155 else
21156 {
21157 209800 s3[0] = MsgStrings[msgstr].s[msgptr];
21158 209800 s3[1] = 0;
21159 }
21160 233741 }
21161
21162 // Returns true if the pointer is at a string's
21163 // null terminator or a trailing space
21164 805686 bool atend(char const* str)
21165 {
21166 805686 int32_t i=0;
21167
21168
2/2
✓ Branch 0 taken 6343123 times.
✓ Branch 1 taken 805686 times.
7148809 while(str[i]==' ')
21169 6343123 i++;
21170
21171 805686 return str[i]=='\0';
21172 }
21173
21174 14461009 void putmsg()
21175 {
21176 14461009 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
21177
2/2
✓ Branch 0 taken 668922 times.
✓ Branch 1 taken 13792087 times.
14461009 if(!msgorig) msgorig=msgstr;
21178
21179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14461009 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14461009 if(wait_advance && linkedmsgclk < 1)
21180 linkedmsgclk = 1;
21181
2/2
✓ Branch 0 taken 14188326 times.
✓ Branch 1 taken 272683 times.
14461009 if(linkedmsgclk>0)
21182 {
21183
2/2
✓ Branch 0 taken 126232 times.
✓ Branch 1 taken 146451 times.
272683 if(linkedmsgclk==1)
21184 {
21185
6/6
✓ Branch 0 taken 126231 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 123411 times.
✓ Branch 3 taken 2820 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 123303 times.
126232 if(do_end_str||cAbtn()||cBbtn())
21186 {
21187 2929 do_end_str = false;
21188 2929 linkedmsgclk = 0;
21189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2929 times.
2929 if(wait_advance)
21190 {
21191 wait_advance = false;
21192 }
21193 else
21194 {
21195 2929 msgstr=MsgStrings[msgstr].nextstring;
21196 2929 ssc_tile_hei_buf = -1;
21197
3/4
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 1986 times.
✓ Branch 2 taken 943 times.
✗ Branch 3 not taken.
2929 if(!msgstr && enqueued_str)
21198 {
21199 msgstr = enqueued_str;
21200 enqueued_str = 0;
21201 }
21202
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 943 times.
2929 if(!msgstr)
21203 {
21204 943 msgfont=get_zc_font(font_zfont);
21205
21206
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 939 times.
943 if(tmpscr->room!=rGRUMBLE)
21207 939 blockpath=false;
21208
21209 943 dismissmsg();
21210 943 goto disappear;
21211 }
21212
21213 1986 donewmsg(msgstr);
21214 1986 putprices(false);
21215 }
21216 1986 }
21217 125289 }
21218 else
21219 {
21220 146451 --linkedmsgclk;
21221 }
21222 271740 }
21223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14460066 times.
14460066 if(wait_advance) return; //Waiting for buttonpress
21224
21225
10/10
✓ Branch 0 taken 14457739 times.
✓ Branch 1 taken 2327 times.
✓ Branch 2 taken 663737 times.
✓ Branch 3 taken 13794002 times.
✓ Branch 4 taken 527084 times.
✓ Branch 5 taken 136653 times.
✓ Branch 6 taken 263640 times.
✓ Branch 7 taken 263444 times.
✓ Branch 8 taken 854 times.
✓ Branch 9 taken 262786 times.
14460066 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
21226 {
21227
2/2
✓ Branch 0 taken 400951 times.
✓ Branch 1 taken 13794002 times.
14194953 if(!msgstr)
21228 13794002 msgorig=0;
21229
21230 14194953 msg_active = false;
21231 14194953 return;
21232 }
21233
21234 265113 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21235
21236 char s3[145];
21237 int32_t tlength;
21238
21239 // Bypass the string with the B button!
21240
4/4
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 263770 times.
✓ Branch 2 taken 1254 times.
✓ Branch 3 taken 262516 times.
265113 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
21241 {
21242 //finish writing out the string
21243
4/4
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 79061 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 77932 times.
80528 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
21244 {
21245
5/6
✓ Branch 0 taken 18708 times.
✓ Branch 1 taken 59224 times.
✓ Branch 2 taken 18707 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 18707 times.
✗ Branch 5 not taken.
77932 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
21246 1 goto breakout; // break out if message speed was changed to non-zero
21247
4/6
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77931 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 285 times.
✓ Branch 5 taken 77646 times.
77931 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21248 {
21249
1/2
✓ Branch 0 taken 77646 times.
✗ Branch 1 not taken.
77646 if(bottom_margin_clip())
21250 break;
21251
21252 77646 wrapmsgstr(s3);
21253
21254
2/2
✓ Branch 0 taken 20449 times.
✓ Branch 1 taken 57197 times.
77646 if(MsgStrings[msgstr].s[msgptr]==' ')
21255 {
21256 20449 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21257
21258
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1347 times.
21843 if(cursor_x+tlength > (msg_w-msg_margins[right])
21259
5/6
✓ Branch 0 taken 1394 times.
✓ Branch 1 taken 19055 times.
✓ Branch 2 taken 1394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1300 times.
✓ Branch 5 taken 47 times.
20449 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21260 47 ? true : strcmp(s3," ")!=0))
21261 {
21262 1347 ssc_tile_hei = ssc_tile_hei_buf;
21263
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21264 1347 ssc_tile_hei_buf = -1;
21265 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
21266
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
21267 1347 cursor_x=msg_margins[left];
21268 1347 }
21269
21270 20449 char buf[2] = {0};
21271 20449 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21272
21273 20449 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21274
21275 20449 cursor_x+=tlength;
21276 20449 }
21277 else
21278 {
21279 57197 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21280
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 536 times.
57923 if(cursor_x+tlength > (msg_w-msg_margins[right])
21281
5/6
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 56424 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 583 times.
✗ Branch 5 not taken.
57197 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21282 190 ? true : strcmp(s3," ")!=0))
21283 {
21284 773 ssc_tile_hei = ssc_tile_hei_buf;
21285
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21286 773 ssc_tile_hei_buf = -1;
21287 773 cursor_y += thei + MsgStrings[msgstr].vspace;
21288
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(bottom_margin_clip()) break;
21289 773 cursor_x=msg_margins[left];
21290 773 }
21291
21292 57197 sfx(MsgStrings[msgstr].sfx);
21293
21294 57197 char buf[2] = {0};
21295 57197 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21296
21297 57197 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21298
21299 57197 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21300 57197 cursor_x += MsgStrings[msgstr].hspace;
21301 }
21302
21303 77646 msgpos++;
21304 77646 }
21305
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_run_menu)
21306 {
21307 if(runMenuCursor())
21308 {
21309 do_run_menu = false;
21310 }
21311 else break;
21312 }
21313
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(doing_name_insert)
21314 {
21315 if(*nameptr)
21316 {
21317 if(bottom_margin_clip())
21318 break;
21319
21320 char s3[9] = {0};
21321
21322 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21323 {
21324 strcpy(s3, nameptr);
21325 }
21326 else
21327 {
21328 s3[0] = *nameptr;
21329 s3[1] = 0;
21330 }
21331
21332 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21333
21334 if(cursor_x+tlength > (msg_w-msg_margins[right])
21335 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21336 ? true : strcmp(s3," ")!=0))
21337 {
21338 ssc_tile_hei = ssc_tile_hei_buf;
21339 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21340 ssc_tile_hei_buf = -1;
21341 cursor_y += thei + MsgStrings[msgstr].vspace;
21342 if(bottom_margin_clip()) break;
21343 cursor_x=msg_margins[left];
21344 }
21345
21346 sfx(MsgStrings[msgstr].sfx);
21347
21348 char buf[2] = {0};
21349 sprintf(buf,"%c",*nameptr);
21350
21351 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21352
21353 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21354 cursor_x += MsgStrings[msgstr].hspace;
21355 ++nameptr;
21356 continue; //don't advance the msgptr, as the next char in it was not processed!
21357 }
21358 else doing_name_insert = false;
21359 }
21360 77931 ++msgptr;
21361
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_end_str)
21362 goto strendcheck;
21363
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(wait_advance)
21364 return;
21365
2/2
✓ Branch 0 taken 76718 times.
✓ Branch 1 taken 1213 times.
77931 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21366 {
21367
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 786 times.
1213 if(MsgStrings[msgstr].nextstring)
21368 {
21369
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21370 {
21371 msgstr=MsgStrings[msgstr].nextstring;
21372 msgpos=msgptr=0;
21373 msgfont=setmsgfont();
21374 }
21375 786 }
21376 1213 }
21377 }
21378
21379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if (!do_run_menu)
21380 {
21381 1232 msgclk = 72;
21382 1232 msgpos = 10000;
21383 1232 }
21384 1232 }
21385 else
21386 262516 {
21387 breakout:
21388 262517 word tempspeed = msgspeed;
21389
2/2
✓ Branch 0 taken 261554 times.
✓ Branch 1 taken 963 times.
262517 if (do_run_menu)
21390 963 tempspeed = 0;
21391
6/6
✓ Branch 0 taken 210795 times.
✓ Branch 1 taken 51722 times.
✓ Branch 2 taken 120294 times.
✓ Branch 3 taken 90501 times.
✓ Branch 4 taken 113455 times.
✓ Branch 5 taken 6839 times.
262517 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
21392 97340 return;
21393 }
21394
21395 // Start writing the string
21396
2/2
✓ Branch 0 taken 163526 times.
✓ Branch 1 taken 2883 times.
169292 if(msgptr == 0)
21397 {
21398
2/2
✓ Branch 0 taken 2883 times.
✓ Branch 1 taken 5068 times.
7951 while(MsgStrings[msgstr].s[msgptr]==' ')
21399 {
21400 5068 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21401
21402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
5156 if(cursor_x+tlength > (msg_w-msg_margins[right])
21403
4/6
✓ Branch 0 taken 4980 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
5068 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21404 ? 1 : strcmp(s3," ")!=0))
21405 {
21406 88 ssc_tile_hei = ssc_tile_hei_buf;
21407
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21408 88 ssc_tile_hei_buf = -1;
21409 88 cursor_y += thei + MsgStrings[msgstr].vspace;
21410
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(bottom_margin_clip()) break;
21411 88 cursor_x=msg_margins[left];
21412 88 }
21413
21414 5068 cursor_x+=tlength;
21415 5068 ++msgptr;
21416 5068 ++msgpos;
21417
21418 // The "Continue From Previous" feature
21419
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1368 times.
5068 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21420 {
21421
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
21422 {
21423 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21424 {
21425 msgstr=MsgStrings[msgstr].nextstring;
21426 msgpos=msgptr=0;
21427 msgfont=setmsgfont();
21428 }
21429 }
21430 1368 }
21431 }
21432 2883 }
21433
21434 reparsesinglechar:
21435 // Continue printing the string!
21436
3/4
✓ Branch 0 taken 159832 times.
✓ Branch 1 taken 6579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 159832 times.
326240 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
21437 {
21438
6/6
✓ Branch 0 taken 158869 times.
✓ Branch 1 taken 963 times.
✓ Branch 2 taken 158845 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2750 times.
✓ Branch 5 taken 156095 times.
159832 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21439 {
21440 156095 wrapmsgstr(s3);
21441
21442 156095 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21443
21444
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1867 times.
158218 if(cursor_x+tlength > (msg_w-msg_margins[right])
21445
6/6
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 153929 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 1867 times.
✓ Branch 5 taken 43 times.
156095 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21446 256 ? true : strcmp(s3," ")!=0))
21447 {
21448 2123 ssc_tile_hei = ssc_tile_hei_buf;
21449
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21450 2123 ssc_tile_hei_buf = -1;
21451 2123 cursor_y += thei + MsgStrings[msgstr].vspace;
21452
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(bottom_margin_clip()) goto strendcheck;
21453 2123 cursor_x=msg_margins[left];
21454 //if(space) s3[0]=0;
21455 2123 }
21456
21457 156095 sfx(MsgStrings[msgstr].sfx);
21458
21459 156095 char buf[2] = {0};
21460 156095 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21461
21462 156095 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21463
21464 156095 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21465 156095 cursor_x += MsgStrings[msgstr].hspace;
21466 156095 msgpos++;
21467 156095 }
21468
2/2
✓ Branch 0 taken 159831 times.
✓ Branch 1 taken 1 times.
159832 if(do_end_str)
21469 1 goto strendcheck;
21470
1/2
✓ Branch 0 taken 159831 times.
✗ Branch 1 not taken.
159831 if(wait_advance)
21471 {
21472 ++msgptr;
21473 return;
21474 }
21475
2/2
✓ Branch 0 taken 965 times.
✓ Branch 1 taken 158866 times.
159831 else if(do_run_menu)
21476 {
21477
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 963 times.
965 if(runMenuCursor())
21478 {
21479 2 do_run_menu = false;
21480 2 ++msgptr;
21481 2 goto reparsesinglechar;
21482 }
21483 963 }
21484
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 158836 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
158866 else if(doing_name_insert && *nameptr)
21485 {
21486 24 char s3[9] = {0};
21487
21488
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21489 {
21490 24 strcpy(s3, nameptr);
21491 24 }
21492 else
21493 {
21494 s3[0] = *nameptr;
21495 s3[1] = 0;
21496 }
21497
21498 24 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21499
21500
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if(cursor_x+tlength > (msg_w-msg_margins[right])
21501
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21502 ? true : strcmp(s3," ")!=0))
21503 {
21504 ssc_tile_hei = ssc_tile_hei_buf;
21505 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21506 ssc_tile_hei_buf = -1;
21507 cursor_y += thei + MsgStrings[msgstr].vspace;
21508 if(bottom_margin_clip()) goto strendcheck;
21509 cursor_x=msg_margins[left];
21510 }
21511
21512 24 sfx(MsgStrings[msgstr].sfx);
21513
21514 24 char buf[2] = {0};
21515 24 sprintf(buf,"%c",*nameptr);
21516
21517 24 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21518
21519 24 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21520 24 cursor_x += MsgStrings[msgstr].hspace;
21521 24 ++nameptr;
21522 24 }
21523 else
21524 {
21525 158842 doing_name_insert = false;
21526 158842 msgptr++;
21527
21528
2/2
✓ Branch 0 taken 156149 times.
✓ Branch 1 taken 2693 times.
158842 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21529 {
21530
2/2
✓ Branch 0 taken 1492 times.
✓ Branch 1 taken 1201 times.
2693 if(MsgStrings[msgstr].nextstring)
21531 {
21532
1/2
✓ Branch 0 taken 1201 times.
✗ Branch 1 not taken.
1201 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21533 {
21534 msgstr=MsgStrings[msgstr].nextstring;
21535 msgpos=msgptr=0;
21536 msgfont=setmsgfont();
21537 }
21538 1201 }
21539 2693 }
21540
21541
2/2
✓ Branch 0 taken 23711 times.
✓ Branch 1 taken 4519 times.
187072 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21542
2/2
✓ Branch 0 taken 158321 times.
✓ Branch 1 taken 521 times.
158842 && (MsgStrings[msgstr].s[msgptr]==' ')
21543
2/2
✓ Branch 0 taken 28230 times.
✓ Branch 1 taken 130091 times.
158321 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21544 {
21545
2/2
✓ Branch 0 taken 4513 times.
✓ Branch 1 taken 156761 times.
161274 while(MsgStrings[msgstr].s[msgptr]==' ')
21546 {
21547 156761 msgspace = true;
21548 156761 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21549
21550
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6280 times.
163505 if(cursor_x+tlength > (msg_w-msg_margins[right])
21551
4/6
✓ Branch 0 taken 6744 times.
✓ Branch 1 taken 150017 times.
✓ Branch 2 taken 6744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6280 times.
✗ Branch 5 not taken.
156761 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21552 464 ? true : strcmp(s3," ")!=0))
21553 {
21554 6744 ssc_tile_hei = ssc_tile_hei_buf;
21555
1/2
✓ Branch 0 taken 6744 times.
✗ Branch 1 not taken.
6744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21556 6744 ssc_tile_hei_buf = -1;
21557 6744 cursor_y += thei + MsgStrings[msgstr].vspace;
21558
2/2
✓ Branch 0 taken 6738 times.
✓ Branch 1 taken 6 times.
6744 if(bottom_margin_clip()) break;
21559 6738 cursor_x=msg_margins[left];
21560 6738 }
21561
21562 156755 cursor_x+=tlength;
21563 156755 ++msgpos;
21564 156755 ++msgptr;
21565
21566
2/2
✓ Branch 0 taken 10215 times.
✓ Branch 1 taken 146540 times.
156755 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21567 {
21568
2/2
✓ Branch 0 taken 87448 times.
✓ Branch 1 taken 59092 times.
146540 if(MsgStrings[msgstr].nextstring)
21569 {
21570
1/2
✓ Branch 0 taken 59092 times.
✗ Branch 1 not taken.
59092 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21571 {
21572 msgstr=MsgStrings[msgstr].nextstring;
21573 msgpos=msgptr=0;
21574 msgfont=setmsgfont();
21575 }
21576 59092 }
21577 146540 }
21578 }
21579 4519 }
21580 }
21581 159829 }
21582 strendcheck:
21583 // Done printing the string
21584
14/14
✓ Branch 0 taken 166408 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 166384 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 165421 times.
✓ Branch 5 taken 963 times.
✓ Branch 6 taken 164189 times.
✓ Branch 7 taken 1232 times.
✓ Branch 8 taken 161624 times.
✓ Branch 9 taken 2565 times.
✓ Branch 10 taken 161618 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 159216 times.
✓ Branch 13 taken 6205 times.
166409 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21585 {
21586
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6205 times.
6206 if(!do_end_str)
21587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6205 times.
6205 while(parsemsgcode()); // Finish remaining control codes
21588
21589 // Go to next string, or make it disappear by going to string 0.
21590
5/6
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
✓ Branch 2 taken 3275 times.
✓ Branch 3 taken 944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
6206 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21591 {
21592 2931 linkedmsgclk=do_end_str?1:51;
21593 2931 }
21594
21595
2/2
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
6206 if(MsgStrings[msgstr].nextstring==0)
21596 {
21597
2/2
✓ Branch 0 taken 944 times.
✓ Branch 1 taken 3275 times.
4219 if(!get_qr(qr_MSGDISAPPEAR))
21598 3275 {
21599 disappear:
21600 4218 msg_active = false;
21601 4218 Hero.finishedmsg();
21602 4218 }
21603
21604
2/2
✓ Branch 0 taken 5149 times.
✓ Branch 1 taken 13 times.
5162 if(repaircharge)
21605 {
21606 // if (get_qr(qr_REPAIRFIX)) {
21607 // fixed_door=true;
21608 // }
21609 13 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21610 13 repaircharge = 0;
21611 13 }
21612
21613
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(adjustmagic)
21614 {
21615
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
21616 {
21617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(game->get_magicdrainrate())
21618 2 game->set_magicdrainrate(1);
21619 2 }
21620 else if(game->get_magicdrainrate() > 1)
21621 {
21622 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21623 }
21624 2 adjustmagic = false;
21625 2 sfx(WAV_SCALE);
21626
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21627 2 }
21628
21629
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(learnslash)
21630 {
21631 2 game->set_canslash(1);
21632 2 learnslash = false;
21633 2 sfx(WAV_SCALE);
21634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21635 2 }
21636 5162 }
21637 7149 }
21638 14459645 }
21639
21640 124237 int32_t message_more_y()
21641 {
21642 //Is the flag ticked, do we really want a message more y larger than 160?
21643
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124209 times.
✓ Branch 2 taken 124237 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124209 times.
✓ Branch 5 taken 28 times.
124237 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21644 124237 msgy+=playing_field_offset;
21645 124237 return msgy;
21646 }
21647
21648 /*** Collision detection & handling ***/
21649
21650 14161234 void clear_script_one_frame_conditions()
21651 {
21652
2/2
✓ Branch 0 taken 38756679 times.
✓ Branch 1 taken 14161234 times.
52917913 for(int32_t j=0; j<guys.Count(); j++)
21653 {
21654 38756679 enemy *e = (enemy*)guys.spr(j);
21655
2/2
✓ Branch 0 taken 658863543 times.
✓ Branch 1 taken 38756679 times.
697620222 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21656 38756679 }
21657 14161234 }
21658
21659 4844814 void check_enemy_lweapon_collision(weapon *w)
21660 {
21661
8/8
✓ Branch 0 taken 4236308 times.
✓ Branch 1 taken 608506 times.
✓ Branch 2 taken 3248364 times.
✓ Branch 3 taken 987944 times.
✓ Branch 4 taken 3186280 times.
✓ Branch 5 taken 62084 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3169542 times.
4844814 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21662 {
21663
2/2
✓ Branch 0 taken 3153971 times.
✓ Branch 1 taken 11154292 times.
14308263 for(int32_t j=0; j<guys.Count(); j++)
21664 {
21665 11154292 enemy *e = (enemy*)guys.spr(j);
21666
21667 11154292 bool didhit = e->hit(w);
21668
2/2
✓ Branch 0 taken 10933840 times.
✓ Branch 1 taken 220452 times.
11154292 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21669 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21670 {
21671 // !(e->stunclk)
21672 220452 int32_t h = e->takehit(w);
21673
2/2
✓ Branch 0 taken 187020 times.
✓ Branch 1 taken 33432 times.
220452 if (h == -1)
21674 {
21675 33432 int indx = Lwpns.find(w);
21676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33432 times.
33432 if(indx > -1)
21677 33432 e->hitby[HIT_BY_LWEAPON] = indx+1;
21678 33432 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21679 33432 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21680
2/2
✓ Branch 0 taken 2170 times.
✓ Branch 1 taken 31262 times.
33432 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21681 2170 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21682 33432 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21683 33432 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21684
21685 33432 }
21686 //we may need to handle this in special cases. -Z
21687
21688 //if h == stun or ignore
21689
21690 //if e->stun > DEFAULT_STUN -1 || !e->stun
21691 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21692 ///! how about: if w->dead != bounce !
21693
21694 // NOT FOR PUBLIC RELEASE
21695 /*if(h==3) //Mirror shield
21696 {
21697 if (w->id==ewFireball || w->id==wRefFireball)
21698 {
21699 w->id=wRefFireball;
21700 switch(e->dir)
21701 {
21702 case up: e->angle += (PI - e->angle) * 2.0; break;
21703 case down: e->angle = -e->angle; break;
21704 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21705 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21706 // TODO: the following. -L.
21707 case l_up: break;
21708 case r_up: break;
21709 case l_down: break;
21710 case r_down: break;
21711 }
21712 }
21713 else
21714 {
21715 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21716 w->dir ^= 1;
21717 if(w->dir&2)
21718 w->flip ^= 1;
21719 else
21720 w->flip ^= 2;
21721 }
21722 w->ignoreHero=false;
21723 }
21724 else*/
21725
2/2
✓ Branch 0 taken 176421 times.
✓ Branch 1 taken 44031 times.
220452 if(h)
21726 {
21727
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44027 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44031 if(e->switch_hooked && w->family_class == itype_switchhook)
21728 w->onhit(false, e, -1);
21729 44031 else w->onhit(false, e, h);
21730 44031 }
21731
21732
2/2
✓ Branch 0 taken 217778 times.
✓ Branch 1 taken 2674 times.
220452 if(h==2)
21733 {
21734 2674 break;
21735 }
21736 217778 }
21737
21738
2/2
✓ Branch 0 taken 11138721 times.
✓ Branch 1 taken 12897 times.
11151618 if(w->Dead())
21739 {
21740 12897 break;
21741 }
21742 11138721 }
21743
21744 // Item flags added in 2.55:
21745 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
21746 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21747 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21748 // -Em
21749
6/6
✓ Branch 0 taken 2715567 times.
✓ Branch 1 taken 453975 times.
✓ Branch 2 taken 2670995 times.
✓ Branch 3 taken 44572 times.
✓ Branch 4 taken 43559 times.
✓ Branch 5 taken 2627436 times.
3169542 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21750 {
21751 542106 int32_t itype, pitem = w->parentitem;
21752
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453975 times.
✓ Branch 2 taken 43559 times.
✓ Branch 3 taken 44572 times.
542106 switch(w->id)
21753 {
21754 453975 case wBrang: itype = itype_brang; break;
21755 43559 case wArrow: itype = itype_arrow; break;
21756 case wHookshot:
21757 44572 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21758 44572 break;
21759 }
21760
2/2
✓ Branch 0 taken 537254 times.
✓ Branch 1 taken 4852 times.
542106 if(pitem < 0) pitem = current_item_id(itype);
21761
5/6
✓ Branch 0 taken 44572 times.
✓ Branch 1 taken 497534 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44472 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
542106 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
21762 { //Swap with item
21763 for(int32_t j=0; j<items.Count(); j++)
21764 {
21765 if(items.spr(j)->hit(w))
21766 {
21767 item *theItem = ((item*)items.spr(j));
21768 bool priced = theItem->PriceIndex >-1;
21769 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21770 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21771 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21772 {
21773 if(!Hero.switchhookclk)
21774 {
21775 hooked_combopos = -1;
21776 hooked_layerbits = 0;
21777 switching_object = theItem;
21778 theItem->switch_hooked = true;
21779 w->misc = 2;
21780 w->step = 0;
21781 theItem->clk2=256;
21782 Hero.doSwitchHook(game->get_switchhookstyle());
21783 if(QMisc.miscsfx[sfxSWITCHED])
21784 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21785 }
21786 }
21787 }
21788 }
21789 }
21790
6/6
✓ Branch 0 taken 43559 times.
✓ Branch 1 taken 498547 times.
✓ Branch 2 taken 374087 times.
✓ Branch 3 taken 330528 times.
✓ Branch 4 taken 498547 times.
✓ Branch 5 taken 330528 times.
542106 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21791 {
21792
2/2
✓ Branch 0 taken 87310 times.
✓ Branch 1 taken 374087 times.
461397 for(int32_t j=0; j<items.Count(); j++)
21793 {
21794
2/2
✓ Branch 0 taken 82412 times.
✓ Branch 1 taken 4898 times.
87310 if(items.spr(j)->hit(w))
21795 {
21796 4898 item *theItem = ((item*)items.spr(j));
21797 4898 bool priced = theItem->PriceIndex >-1;
21798
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21799
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21800
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
21801 {
21802
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21803 {
21804 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21805 }
21806
21807 1724 Hero.checkitems(j);
21808 1724 }
21809 4898 }
21810 87310 }
21811 374087 }
21812
2/2
✓ Branch 0 taken 14738 times.
✓ Branch 1 taken 153281 times.
829075 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21813 {
21814
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21815 {
21816
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21817 {
21818 8688 item *theItem = ((item*)items.spr(j));
21819 8688 bool priced = theItem->PriceIndex >-1;
21820
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21821
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21822
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21823 {
21824 7273 int32_t pickup = theItem->pickup;
21825 7273 int32_t id2 = theItem->id;
21826 7273 int32_t pstr = theItem->pstring;
21827 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21828
21829 7273 std::vector<int32_t> &ev = FFCore.eventData;
21830 7273 ev.clear();
21831 7273 ev.push_back(id2*10000);
21832 7273 ev.push_back(pickup*10000);
21833 7273 ev.push_back(pstr*10000);
21834 7273 ev.push_back(pstr_flags*10000);
21835 7273 ev.push_back(0);
21836 7273 ev.push_back(theItem->getUID());
21837 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21838 7273 ev.push_back(w->getUID());
21839
21840 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21841 7273 bool nullify = ev[4] != 0;
21842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21843
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21844 {
21845 6197 w->onhit(false);
21846 6197 }
21847
21848
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21849 {
21850 498 w->dead=1;
21851 498 theItem->clk2=256;
21852 498 w->dragging=j;
21853 498 theItem->is_dragged = true;
21854 498 }
21855 7273 }
21856 8688 }
21857 36900 }
21858 153281 }
21859 542106 }
21860 3169542 }
21861 4844814 }
21862 14159079 void check_collisions()
21863 {
21864
2/2
✓ Branch 0 taken 4844774 times.
✓ Branch 1 taken 14159079 times.
19003853 for(uint q = 0; q < Lwpns.Count(); ++q)
21865 4844774 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21866 14159079 }
21867
21868 14161234 void dragging_item()
21869 {
21870
2/2
✓ Branch 0 taken 4959446 times.
✓ Branch 1 taken 14161234 times.
19120680 for(int32_t i=0; i<Lwpns.Count(); i++)
21871 {
21872 4959446 weapon *w = (weapon*)Lwpns.spr(i);
21873
21874
4/4
✓ Branch 0 taken 4496882 times.
✓ Branch 1 taken 462564 times.
✓ Branch 2 taken 4804187 times.
✓ Branch 3 taken 155259 times.
4959446 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
21875 {
21876
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21877 {
21878 7247 item* dragItem = (item*)items.spr(w->dragging);
21879 7247 dragItem->x=w->x;
21880 7247 dragItem->y=w->y;
21881
21882 // Drag the Fairy enemy as well as the Fairy item
21883 7247 int32_t id = dragItem->id;
21884
21885
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 404 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21886 {
21887 404 movefairynew2(w->x,w->y,*dragItem);
21888 404 }
21889 7247 }
21890 155259 }
21891 4959446 }
21892 14161234 }
21893
21894 55 int32_t more_carried_items()
21895 {
21896 55 int32_t hasmorecarries = 0;
21897
21898
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 55 times.
115 for(int32_t i=0; i<items.Count(); i++)
21899 {
21900
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 55 times.
60 if(((item*)items.spr(i))->pickup & ipENEMY)
21901 {
21902 55 hasmorecarries++;
21903 55 }
21904 60 }
21905
21906 55 return hasmorecarries;
21907 }
21908
21909 // messy code to do the enemy-carrying-the-item thing
21910 14161234 void roaming_item()
21911 {
21912
4/4
✓ Branch 0 taken 28207 times.
✓ Branch 1 taken 14133027 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 28137 times.
14161234 if(!(hasitem&(4|2)) || !loaded_enemies)
21913 14133097 return;
21914
21915 // All enemies already dead upon entering a room?
21916
1/2
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
28137 if(guys.Count()==0)
21917 {
21918 return;
21919 }
21920
21921 // Lost track of the carrier?
21922
5/6
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28131 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 28115 times.
✓ Branch 5 taken 16 times.
28137 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21923 28131 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21924 {
21925 22 guycarryingitem=-1;
21926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 for(int32_t j=0; j<guys.Count(); j++)
21927 {
21928
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 22 times.
84 if(((enemy*)guys.spr(j))->itemguy)
21929 {
21930 22 guycarryingitem=j;
21931 22 break;
21932 }
21933 62 }
21934 22 }
21935
21936
2/2
✓ Branch 0 taken 28073 times.
✓ Branch 1 taken 64 times.
28137 if(hasitem&4)
21937 {
21938 64 guycarryingitem = -1;
21939
21940
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 64 times.
477 for(int32_t i=0; i<guys.Count(); i++)
21941 {
21942
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 64 times.
413 if(((enemy*)guys.spr(i))->itemguy)
21943 {
21944 64 guycarryingitem = i;
21945 64 }
21946 413 }
21947
21948
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(guycarryingitem == -1) //This happens when "default enemies" such as
21949 {
21950 return; //eSHOOTFBALL are alive but enemies from the list
21951 } //are not. Defer to HeroClass::checkspecial().
21952
21953 64 int32_t Item=tmpscr->item;
21954
21955 64 hasitem &= ~4;
21956
21957
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21958 {
21959 115 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21960
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 13 times.
64 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21961 );
21962 64 hasitem |= 2;
21963 64 }
21964 else
21965 {
21966 return;
21967 }
21968 64 }
21969
21970
2/2
✓ Branch 0 taken 29483 times.
✓ Branch 1 taken 28137 times.
57620 for(int32_t i=0; i<items.Count(); i++)
21971 {
21972
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 28137 times.
29483 if(((item*)items.spr(i))->pickup&ipENEMY)
21973 {
21974
2/2
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 13865 times.
28137 if(get_qr(qr_HIDECARRIEDITEMS))
21975 {
21976 14272 items.spr(i)->x = -128; // Awfully inelegant, innit?
21977 14272 items.spr(i)->y = -128;
21978 14272 }
21979
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21980 {
21981
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21982 {
21983 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21984 {
21985 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21986 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21987 }
21988 else
21989 {
21990 if(guys.spr(guycarryingitem)->extend >= 3)
21991 {
21992 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21993 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21994 }
21995 else
21996 {
21997 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21998 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21999 }
22000 }
22001 items.spr(i)->z = guys.spr(guycarryingitem)->z;
22002 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
22003 }
22004 else
22005 {
22006 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
22007 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
22008 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
22009 }
22010 13865 }
22011 28137 }
22012 29483 }
22013 14161234 }
22014
22015 bool enemy::IsBigAnim()
22016 {
22017 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
22018 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
22019 || anim == a4FRM8DIRB);
22020 }
22021 2387490 int32_t enemy::getFlashingCSet()
22022 {
22023 //Special cset for the dying sprite
22024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2387490 times.
2387490 if(dying)
22025 {
22026 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
22027 return wpnsbuf[spr_death].csets & 15;
22028 else
22029 return (((clk2 + 5) >> 1) & 3) + 6;
22030 }
22031
22032 //Normal cset
22033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2387490 times.
2387490 if (hclk <= 0)
22034 {
22035 //Special cset for the flashing animation
22036 if (flags2 & guy_flashing)
22037 return (frame & 3) + 6;
22038 return cs;
22039 }
22040
22041 //Hurt animations
22042
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2383602 times.
2387490 if(family==eeGANON)
22043 3888 return (((hclk-1)>>1)&3)+6;
22044
4/4
✓ Branch 0 taken 2214805 times.
✓ Branch 1 taken 168797 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1727667 times.
2383602 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
22045 1727667 return (((hclk-1)>>1)&3)+6;
22046
22047 655935 return cs;
22048 2387490 }
22049
22050 81506626 bool enemy::is_hitflickerframe(bool olddrawing)
22051 {
22052
6/6
✓ Branch 0 taken 81478122 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3938144 times.
✓ Branch 3 taken 77539978 times.
✓ Branch 4 taken 3165453 times.
✓ Branch 5 taken 772691 times.
81506626 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
22053 80733935 return false;
22054
22055
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
22056 return false;
22057
22058 772691 int32_t fr = game->get_spriteflickerspeed();
22059
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
22060 return true;
22061 772691 return frame % (fr * 2) < fr;
22062 81506626 }
22063
22064 const char *old_guy_string[OLDMAXGUYS] =
22065 {
22066 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
22067 // 020
22068 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
22069 // 025
22070 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
22071 // 030
22072 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
22073 // 035
22074 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
22075 // 040
22076 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
22077 // 045
22078 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
22079 // 050
22080 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
22081 // 055
22082 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
22083 // 060
22084 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
22085 // 065
22086 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
22087 // 070
22088 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
22089 // 075
22090 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
22091 // 080
22092 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
22093 // 085
22094 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
22095 // 090
22096 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
22097 // 095
22098 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
22099 // 100
22100 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
22101 // 105
22102 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
22103 // 110
22104 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
22105 // 115
22106 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
22107 // 120
22108 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
22109 // 125
22110 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
22111 // 130
22112 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
22113 // 135
22114 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
22115 // 140
22116 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
22117 // 145
22118 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
22119 // 150
22120 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
22121 // 155
22122 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
22123 // 160
22124 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
22125 // 165
22126 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
22127 // 170
22128 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
22129 // 175
22130 "Grappler Bug (HP) ", "Grappler Bug (MP) "
22131 };
22132